Skip to content

Commit

Permalink
Ensure depth function is GL_LEQUAL in Qt widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
sankhesh committed Nov 13, 2020
1 parent 4164413 commit cdab8fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 5 additions & 3 deletions GUISupport/Qt/QVTKOpenGLNativeWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ void QVTKOpenGLNativeWidget::paintGL()
this->Superclass::paintGL();
if (this->RenderWindow)
{
auto ostate = this->RenderWindow->GetState();
ostate->Reset();
ostate->Push();
// By default, Qt sets the depth function to GL_LESS but VTK expects GL_LEQUAL
ostate->vtkglDepthFunc(GL_LEQUAL);
Q_ASSERT(this->RenderWindowAdapter);
this->RenderWindowAdapter->paint();

Expand All @@ -255,9 +260,6 @@ void QVTKOpenGLNativeWidget::paintGL()
// before proceeding with blit-ing.
this->makeCurrent();

auto ostate = this->RenderWindow->GetState();
ostate->Reset();
ostate->Push();
const QSize deviceSize = this->size() * this->devicePixelRatioF();
this->RenderWindowAdapter->blit(
this->defaultFramebufferObject(), GL_COLOR_ATTACHMENT0, QRect(QPoint(0, 0), deviceSize));
Expand Down
9 changes: 5 additions & 4 deletions GUISupport/Qt/QVTKOpenGLWindow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ void QVTKOpenGLWindow::paintGL()
this->Superclass::paintGL();
if (this->RenderWindow)
{
auto ostate = this->RenderWindow->GetState();
ostate->Reset();
ostate->Push();
// By default, Qt sets the depth function to GL_LESS but VTK expects GL_LEQUAL
ostate->vtkglDepthFunc(GL_LEQUAL);
Q_ASSERT(this->RenderWindowAdapter);
this->RenderWindowAdapter->paint();

Expand All @@ -247,10 +252,6 @@ void QVTKOpenGLWindow::paintGL()
// before proceeding with blit-ing.
this->makeCurrent();

auto ostate = this->RenderWindow->GetState();
ostate->Reset();
ostate->Push();

const QSize deviceSize = this->size() * this->devicePixelRatioF();
const auto fmt = this->context()->format();
if (fmt.stereo() && this->RenderWindow->GetStereoRender() &&
Expand Down

0 comments on commit cdab8fa

Please sign in to comment.