[vtkusers] Mixing OpenGL and vtk view
Jean-Dominique Barnichon
jeando.barnichon at free.fr
Tue Jul 1 17:15:08 EDT 2003
Hi,
I'm writting an application (VC++6.0, vtk4.0,) based on the doc/view
architecture, in which there are 2 views.
These 2 views are derived from the MFC View class.
The first view uses OpenGL directly
COpenGLView::OnPaint()
{
CDC* m_pDC = new CClientDC(this);
SetupPixelFormat();
HGLRC m_hRC = wglCreateContext (m_pDC->GetSafeHdc());
wglMakeCurrent (m_pDC->GetSafeHdc(), m_hRC);
...
...
SwapBuffers( m_pDC->GetSafeHdc());
wglMakeCurrent (NULL,NULL);
wglDeleteContext (m_hRC);
if(m_pDC) delete m_pDC;
}
The second view uses vtk (based on the MFC sample given in the distribution
files).
When only one of these view is open, all is ok.
The problem comes when the "vtk" view is opened while the "OpenGL" view is
already opened.
Everything is fine as long as the "OpenGL" view does not receives a WM_PAINT
message.
If this happens (for instance when you move the "vtk" view above the
"OpenGL" view),
all interactions (zoom, rotate...) of the "vtk" view no longer work.
I suspect that the following line in COpenGLView::OnPaint() may cause
trouble to the "vtk" view :
wglMakeCurrent (m_pDC->GetSafeHdc (), m_hRC)
as when this line is removed, the vtk interactor works fine (but the OpenGL
view dislpay nothing).
Does this mean that OpenGL and vtk view cannot be used in the same
application?
Or more probably what am I doing wrong?
Thanks for any advice/idea
Jean-Do
More information about the vtkusers
mailing list