[vtkusers] Rendering VTK inside a QGLWidget
Clinton Stimpson
clinton at elemtech.com
Mon Oct 17 11:33:11 EDT 2011
On Monday, October 17, 2011 03:06:06 am Paul Rossi wrote:
> Hi Clint, so after having played around a little with the
> vtkGraphLayoutView, following your tips, i found out that this class
> seemingly works fine inside a simple qglwidget, but in the framework i use
> it doesnt work properly (for some reasons which i dont know, perhaps the
> fbo usage)
>
> essentially, the problem is this line:
>
> m_vtkGraphLayoutView = vtkGraphLayoutView::New();
>
> which causes "stack overflow" as OpenGL error.
>
> Maybe this happens because the vtkGraphLayoutView comes with a
> renderwindow, which interferes somehow with opengl? Do you have any idea
> how to solve this? by the way, i found in the RenderViewBase class
> documentation the following:
>
> In order to use the view with a QVTKWidget the following code is required
> to ensure the interactor and render window are initialized properly.
>
> QVTKWidget *widget = new QVTKWidget;
> vtkContextView *view = vtkContextView::New();
> view->SetInteractor(widget->GetInteractor());
> widget->SetRenderWindow(view->GetRenderWindow());
>
> the problem is that it is not possible to do this with a qglwidget..
>
It is possible, the GraphicsView example in VTK shows a vtkGraphLayoutView
with an FBO, which is nearly the same as yours. It calls
view::SetInteractor() then view::SetRenderWindow(). The main point is to call
SetInteractor first, due to behavior in vtkRenderView.
Have you looked at whether you need to register an observer for events from
vtkGenericOpenGLRenderWindow to make sure the context is ready for a render?
If you are getting a stack overflow, then you'll need to debug it and track
down where there is a push (matrix, attrib, etc...) without a pop.
If it works outside your framework, but not inside... then that'll require
some debugging on your side. Good luck.
--
Clinton Stimpson
Elemental Technologies, Inc
Computational Simulation Software, LLC
www.csimsoft.com
More information about the vtkusers
mailing list