Commit 3784f6d0 authored by Clinton Stimpson's avatar Clinton Stimpson
Browse files

Fix issue with context timestamp when using QVTKWidget2.

Change-Id: Ic5bc394e6cbe3d9ab8bedf1809af72912aa94411
parent c3f21735
......@@ -44,6 +44,7 @@ class GraphicsView : public QGraphicsView
p->beginNativePainting();
#endif
mWidget->GetRenderWindow()->PushState();
mWidget->GetRenderWindow()->OpenGLInitState();
mWidget->GetRenderWindow()->Render();
mWidget->GetRenderWindow()->PopState();
#if QT_VERSION >= 0x040600
......
......@@ -137,7 +137,7 @@ void QVTKGraphicsItem::Start()
}
mWin->PushState();
mWin->OpenGLInit();
mWin->OpenGLInitState();
}
void QVTKGraphicsItem::End()
......
......@@ -202,7 +202,7 @@ void QVTKWidget2::Start()
{
makeCurrent();
mRenWin->PushState();
mRenWin->OpenGLInit();
mRenWin->OpenGLInitState();
}
void QVTKWidget2::End()
......@@ -210,6 +210,15 @@ void QVTKWidget2::End()
mRenWin->PopState();
}
void QVTKWidget2::initializeGL()
{
if(!this->mRenWin)
{
return;
}
this->mRenWin->OpenGLInitContext();
}
/*! handle resize event
*/
void QVTKWidget2::resizeGL(int w, int h)
......
......@@ -99,6 +99,8 @@ protected Q_SLOTS:
virtual void SupportsOpenGL(vtkObject* caller, unsigned long vtk_event, void* client_data, void* call_data);
protected:
// overloaded initialize handler
virtual void initializeGL();
// overloaded resize handler
virtual void resizeGL(int, int);
// overloaded paint handler
......
......@@ -238,38 +238,18 @@ void vtkOpenGLRenderWindow::StereoUpdate(void)
void vtkOpenGLRenderWindow::OpenGLInit()
{
// When a new OpenGL context is created, force an update
// of the extension manager by calling modified on it.
vtkOpenGLExtensionManager *extensions = this->GetExtensionManager();
extensions->Modified();
OpenGLInitContext();
OpenGLInitState();
}
this->ContextCreationTime.Modified();
void vtkOpenGLRenderWindow::OpenGLInitState()
{
glMatrixMode( GL_MODELVIEW );
glDepthFunc( GL_LEQUAL );
glEnable( GL_DEPTH_TEST );
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
// initialize blending for transparency
// We have to set the function pointer to null, otherwise the following
// scenario would fail on Windows (and maybe other kind of configurations):
// 1. Render onscreen on GPU that supports OpenGL 1.4
// 2. Switch to offscreen with GDI Windows implementation (1.1)
vtkgl::BlendFuncSeparate=0;
// Try to initialize vtkgl::BlendFuncSeparate() if available.
if (extensions->ExtensionSupported("GL_VERSION_1_4"))
{
extensions->LoadExtension("GL_VERSION_1_4");
}
else
{
if (extensions->ExtensionSupported("GL_EXT_blend_func_separate"))
{
extensions->LoadCorePromotedExtension("GL_EXT_blend_func_separate");
}
}
if(vtkgl::BlendFuncSeparate!=0)
{
vtkgl::BlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
......@@ -323,6 +303,34 @@ void vtkOpenGLRenderWindow::OpenGLInit()
glPixelStorei(GL_PACK_ALIGNMENT,1);
}
void vtkOpenGLRenderWindow::OpenGLInitContext()
{
// When a new OpenGL context is created, force an update
// of the extension manager by calling modified on it.
vtkOpenGLExtensionManager *extensions = this->GetExtensionManager();
extensions->Modified();
this->ContextCreationTime.Modified();
// We have to set the function pointer to null, otherwise the following
// scenario would fail on Windows (and maybe other kind of configurations):
// 1. Render onscreen on GPU that supports OpenGL 1.4
// 2. Switch to offscreen with GDI Windows implementation (1.1)
vtkgl::BlendFuncSeparate=0;
// Try to initialize vtkgl::BlendFuncSeparate() if available.
if (extensions->ExtensionSupported("GL_VERSION_1_4"))
{
extensions->LoadExtension("GL_VERSION_1_4");
}
else
{
if (extensions->ExtensionSupported("GL_EXT_blend_func_separate"))
{
extensions->LoadCorePromotedExtension("GL_EXT_blend_func_separate");
}
}
}
void vtkOpenGLRenderWindow::PrintSelf(ostream& os, vtkIndent indent)
{
......
......@@ -107,6 +107,12 @@ public:
// Initialize OpenGL for this window.
virtual void OpenGLInit();
// Initialize the state of OpenGL that VTK wants for this window
virtual void OpenGLInitState();
// Initialize VTK for rendering in a new OpenGL context
virtual void OpenGLInitContext();
// Description:
// Return the OpenGL name of the back left buffer.
// It is GL_BACK_LEFT if GL is bound to the window-system-provided
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment