Somebody can help me ,I use vtkQtWidgetWidget in openvr ,when i set ‘SetInteractor’ function, my app will quit. thanks! code like this:
vtkNew cam;
vtkNew renderer;
vtkNew renderWindow;
renderWindow->AddRenderer(renderer);
renderWindow->SetWindowName(“OpenVRTessellatedBoxSource”);
vtkNew iren;
iren->SetRenderWindow(renderWindow);
QPushButton hello(“Hello world!”, 0);
It looks like you are starting from the existing test which is good. But your pseudocode leaves out a lot of specifics (such as what all the vtkNew are. My guess is that you are trying to do this in VR but are not explicitly creating the RenderWindow, Renderer, RenderWindowInteractor and Camera for the VR system. So one of them is not correct and is causing a crash.
Thank you for reply, I use vtkQtwidgetwidget test demo ,it is good.but I want use vtkQTWidgetWidget in VR,you say VR releated object ,I has created,but still crash.
use Qt msvc2017 vtk9.0
That looks correct from my quick look, can you try that on VTK master? There are a lot of VR related changes/fixes since vtk 9.0 That may solve it for you? If not a stack trace of the crash would help
In vtk9.02, crash code like this:
// handle any setup required, only call when OpenGL context is active
void vtkQWidgetTexture::AllocateFromWidget()
{
if (this->OffscreenSurface && this->Framebuffer)
{
return;
}
// the Qt code can modify a lot of OpenGL State
// some of which we may want to preserve
auto state = this->Context->GetState();
vtkOpenGLState::ScopedglEnableDisable state0(state, GL_BLEND);
vtkOpenGLState::ScopedglEnableDisable state1(state, GL_DEPTH_TEST);
vtkOpenGLState::ScopedglEnableDisable state2(state, GL_SCISSOR_TEST); #ifdef GL_MULTISAMPLE
vtkOpenGLState::ScopedglEnableDisable state3(state, GL_MULTISAMPLE); #endif
vtkOpenGLState::ScopedglBlendFuncSeparate state5(state);
vtkOpenGLState::ScopedglDepthFunc state6(state);
vtkOpenGLState::ScopedglViewport state7(state);
// typically just created once, maybe no OpenGL
if (!this->OffscreenSurface)
{
if (!this->Widget)
{
return;
}
this->OffscreenSurface = new QOffscreenSurface();
this->OffscreenSurface->create();
this->Scene = new QGraphicsScene();
this->Widget->move(0, 0);
this->Scene->addWidget(this->Widget);
QObject::connect(this->Scene, &QGraphicsScene::changed, this->RedrawMethod);
}
// Framebuffer gets freed when ReleaseGraphicsResources is called
// so re setup as needed
if (!this->Framebuffer)
{
this->Framebuffer =
new QOpenGLFramebufferObject(this->Widget->width(), this->Widget->height(), GL_TEXTURE_2D);
this->RedrawMethod();
}
}
But I have other problem, At VTK9.1 branch,in OpenVR/Testing medical.cxx run crach. when I modify it which can run ,but render volume will follow by headset rotate,I want the volume which dont move when i rotate my headset .