Skip to content

Commit

Permalink
Initialize the opengl state with proper depth function in QVTK widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
sankhesh committed Nov 17, 2020
1 parent cdab8fa commit 6709f11
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions GUISupport/Qt/QVTKOpenGLNativeWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ void QVTKOpenGLNativeWidget::initializeGL()
{
Q_ASSERT(this->RenderWindowAdapter.data() == nullptr);

auto ostate = this->RenderWindow->GetState();
ostate->Reset();
// By default, Qt sets the depth function to GL_LESS but VTK expects GL_LEQUAL
ostate->vtkglDepthFunc(GL_LEQUAL);

// When a QOpenGLWidget is told to use a QSurfaceFormat with samples > 0,
// QOpenGLWidget doesn't actually create a context with multi-samples and
// internally changes the QSurfaceFormat to be samples=0. Thus, we can't
Expand Down
6 changes: 6 additions & 0 deletions GUISupport/Qt/QVTKOpenGLWindow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ void QVTKOpenGLWindow::initializeGL()
if (this->RenderWindow)
{
Q_ASSERT(this->RenderWindowAdapter.data() == nullptr);

auto ostate = this->RenderWindow->GetState();
ostate->Reset();
// By default, Qt sets the depth function to GL_LESS but VTK expects GL_LEQUAL
ostate->vtkglDepthFunc(GL_LEQUAL);

this->RenderWindowAdapter.reset(
new QVTKRenderWindowAdapter(this->context(), this->RenderWindow, this));
this->RenderWindowAdapter->setDefaultCursor(this->defaultCursor());
Expand Down

0 comments on commit 6709f11

Please sign in to comment.