[vtkusers] using VTK rendering in an existing OpenGL context
Bryn Lloyd
lloyd at itis.ethz.ch
Thu Mar 10 14:09:20 EST 2011
Hi
I am trying to use some rendering functionality from VTK, inside an existing code base using direct OpenGL calls (on WIN32).
I have figured out from various posts, that I need to set the correct WindowId, ParentId etc. of the vtkWin32OpenGLRenderWindow:
vtkWin32OpenGLRenderWindow* renWin = 0;
void setupVtkRenderWindow(HWND _hWnd, HDC _hDC, HGLRC _hRC)
{
if(renWin == 0)
{
renWin = vtkMyWin32OpenGLRenderWindow::New();
}
renWin->SetWindowId(_hWnd);
renWin->SetParentId(_hWnd);
renWin->SetDeviceContext(_hDC);
renWin->SetContextId(_hRC);
}
Somewhere else, I am calling some OpenGL commands, and then adding a vtkRenderer+vtkActor to the window.
My vtkActor displays in the OpenGL context, but "it overwrites" anything which is displayed by the OpenGL commands.
I have set the vtkRenderer::EraseOff() option, and it seems then no background color is written. For a short while, the existing OpenGL triangles pop up, together with the vtkActor triangles. Then the OpenGL objects vanish again.
Does anybody know what I might have missed, or a project, which has implemented what I am trying to do?
Thanks a lot
Bryn
More information about the vtkusers
mailing list