Commit 29670593 authored by Ken Martin's avatar Ken Martin

clean up the state API and fix Qt widget

Make it so that the state API does not require glew.h
as this causes issues with Qt which has it's own gl
functions and glew #defines clobber them.

Clean up the API for querying opengl state to use the standard
opengl get method signatures.

Fix an issue with the new Qt widget where it was not setting
vtk opengl state.
parent 10e8cdc3
......@@ -34,6 +34,7 @@
#include "vtkInteractorStyleTrackballCamera.h"
#include "vtkNew.h"
#include "vtkObjectFactory.h"
#include "vtkOpenGLState.h"
// #define DEBUG_QVTKOPENGL_WIDGET
#ifdef DEBUG_QVTKOPENGL_WIDGET
......@@ -368,6 +369,10 @@ void QVTKOpenGLWidget::recreateFBO()
this->DoVTKRenderInPaintGL = true;
// Clear to ensure that an uninitialized framebuffer is never displayed.
vtkOpenGLState *ostate = this->RenderWindow->GetState();
// have to keep vtk state up to date as well
ostate->vtkglDisable(GL_SCISSOR_TEST);
ostate->vtkglClearColor(0.0f, 0.0f, 0.0f, 1.0f);
f->glDisable(GL_SCISSOR_TEST);
f->glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
f->glClear(GL_COLOR_BUFFER_BIT);
......@@ -465,12 +470,15 @@ void QVTKOpenGLWidget::paintGL()
QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_3_2_Core>();
if (f)
{
vtkOpenGLState *ostate = this->RenderWindow->GetState();
f->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, this->defaultFramebufferObject());
f->glDrawBuffer(GL_COLOR_ATTACHMENT0);
f->glBindFramebuffer(GL_READ_FRAMEBUFFER, this->FBO->handle());
f->glReadBuffer(GL_COLOR_ATTACHMENT0);
f->glDisable(GL_SCISSOR_TEST); // Scissor affects glBindFramebuffer.
ostate->vtkglDisable(GL_SCISSOR_TEST); // Scissor affects glBindFramebuffer.
f->glBlitFramebuffer(0, 0, this->RenderWindow->GetSize()[0], this->RenderWindow->GetSize()[1],
0, 0, this->RenderWindow->GetSize()[0], this->RenderWindow->GetSize()[1], GL_COLOR_BUFFER_BIT,
GL_NEAREST);
......
......@@ -153,9 +153,9 @@ vtkIdType vtkOpenGLContextBufferId::GetPickedItem(int x, int y)
{
glDrawBuffer(GL_BACK_LEFT);
}
ostate->glDisable(GL_DEPTH_TEST);
ostate->glDisable(GL_STENCIL_TEST);
ostate->glDisable(GL_BLEND);
ostate->vtkglDisable(GL_DEPTH_TEST);
ostate->vtkglDisable(GL_STENCIL_TEST);
ostate->vtkglDisable(GL_BLEND);
this->Texture->CopyToFrameBuffer(x,y,x,y,x,y,
this->Context->GetSize()[0],
......
......@@ -330,8 +330,8 @@ void vtkOpenGLContextDevice2D::Begin(vtkViewport* viewport)
vtkOpenGLState *ostate = this->RenderWindow->GetState();
this->Storage->SaveGLState(ostate);
ostate->glDisable(GL_DEPTH_TEST);
ostate->glEnable(GL_BLEND);
ostate->vtkglDisable(GL_DEPTH_TEST);
ostate->vtkglEnable(GL_BLEND);
this->RenderWindow->GetShaderCache()->ReleaseCurrentShader();
......@@ -420,11 +420,11 @@ void vtkOpenGLContextDevice2D::BufferIdModeBegin(
this->ProjectionMatrix->SetMatrix(*matrix);
glDrawBuffer(GL_BACK_LEFT);
ostate->glClearColor(0.0,0.0,0.0,0.0); // id=0 means no hit, just background
ostate->glClear(GL_COLOR_BUFFER_BIT);
ostate->glDisable(GL_STENCIL_TEST);
ostate->glDisable(GL_DEPTH_TEST);
ostate->glDisable(GL_BLEND);
ostate->vtkglClearColor(0.0,0.0,0.0,0.0); // id=0 means no hit, just background
ostate->vtkglClear(GL_COLOR_BUFFER_BIT);
ostate->vtkglDisable(GL_STENCIL_TEST);
ostate->vtkglDisable(GL_DEPTH_TEST);
ostate->vtkglDisable(GL_BLEND);
vtkOpenGLCheckErrorMacro("failed after BufferIdModeBegin");
......@@ -2152,7 +2152,7 @@ void vtkOpenGLContextDevice2D::SetClipping(int *dim)
vp[3] = dim[3];
}
this->RenderWindow->GetState()->glScissor(vp[0], vp[1], vp[2], vp[3]);
this->RenderWindow->GetState()->vtkglScissor(vp[0], vp[1], vp[2], vp[3]);
}
//-----------------------------------------------------------------------------
......
......@@ -310,8 +310,8 @@ public:
{
this->SavedStencilTest = ostate->GetEnumState(GL_STENCIL_TEST);
this->SavedBlend = ostate->GetEnumState(GL_BLEND);
ostate->GetClearColor(this->SavedClearColor);
glGetIntegerv(GL_DRAW_BUFFER, &this->SavedDrawBuffer);
ostate->vtkglGetFloatv(GL_COLOR_CLEAR_VALUE, this->SavedClearColor);
ostate->vtkglGetIntegerv(GL_DRAW_BUFFER, &this->SavedDrawBuffer);
}
}
......@@ -329,7 +329,7 @@ public:
glDrawBuffer(this->SavedDrawBuffer);
}
ostate->glClearColor(this->SavedClearColor[0],
ostate->vtkglClearColor(this->SavedClearColor[0],
this->SavedClearColor[1],
this->SavedClearColor[2],
this->SavedClearColor[3]);
......
......@@ -120,7 +120,7 @@ void vtkOpenGLContextDevice3D::Begin(vtkViewport* vtkNotUsed(viewport))
void vtkOpenGLContextDevice3D::SetMatrices(vtkShaderProgram *prog)
{
vtkOpenGLState *ostate = this->RenderWindow->GetState();
ostate->glDisable(GL_SCISSOR_TEST);
ostate->vtkglDisable(GL_SCISSOR_TEST);
prog->SetUniformMatrix("WCDCMatrix",
this->Device2D->GetProjectionMatrix());
......@@ -615,7 +615,7 @@ void vtkOpenGLContextDevice3D::SetClipping(const vtkRecti &rect)
}
vtkOpenGLState *ostate = this->RenderWindow->GetState();
ostate->glScissor(vp[0], vp[1], vp[2], vp[3]);
ostate->vtkglScissor(vp[0], vp[1], vp[2], vp[3]);
}
void vtkOpenGLContextDevice3D::EnableClipping(bool enable)
......@@ -651,13 +651,13 @@ void vtkOpenGLContextDevice3D::DisableClippingPlane(int i)
void vtkOpenGLContextDevice3D::EnableDepthBuffer()
{
vtkOpenGLState *ostate = this->RenderWindow->GetState();
ostate->glEnable(GL_DEPTH_TEST);
ostate->vtkglEnable(GL_DEPTH_TEST);
}
void vtkOpenGLContextDevice3D::DisableDepthBuffer()
{
vtkOpenGLState *ostate = this->RenderWindow->GetState();
ostate->glDisable(GL_DEPTH_TEST);
ostate->vtkglDisable(GL_DEPTH_TEST);
}
void vtkOpenGLContextDevice3D::PrintSelf(ostream &os, vtkIndent indent)
......
......@@ -122,9 +122,9 @@ void vtkExternalOpenGLCamera::Render(vtkRenderer *ren)
}
}
ostate->glViewport(lowerLeft[0], lowerLeft[1], usize, vsize);
ostate->glEnable(GL_SCISSOR_TEST);
ostate->glScissor(lowerLeft[0], lowerLeft[1], usize, vsize);
ostate->vtkglViewport(lowerLeft[0], lowerLeft[1], usize, vsize);
ostate->vtkglEnable(GL_SCISSOR_TEST);
ostate->vtkglScissor(lowerLeft[0], lowerLeft[1], usize, vsize);
if ((ren->GetRenderWindow())->GetErase() && ren->GetErase()
&& !ren->GetIsPicking())
......
......@@ -455,8 +455,8 @@ int vtkImageDataLIC2D::RequestData(
drawFbo->CheckFrameBufferStatus(GL_FRAMEBUFFER);
drawFbo->InitializeViewport(magVectorSize[0], magVectorSize[1]);
this->Context->GetState()->glClearColor(0.0, 0.0, 0.0, 0.0);
this->Context->GetState()->glClear(GL_COLOR_BUFFER_BIT);
this->Context->GetState()->vtkglClearColor(0.0, 0.0, 0.0, 0.0);
this->Context->GetState()->vtkglClear(GL_COLOR_BUFFER_BIT);
float tcoords[] = {
0.0f, 0.0f,
......
......@@ -290,8 +290,8 @@ public:
// clear the parts of the screen which we will modify
// initially mask all fragments
ostate->glClearColor(0.0, 1.0, 0.0, 0.0);
ostate->glEnable(GL_SCISSOR_TEST);
ostate->vtkglClearColor(0.0, 1.0, 0.0, 0.0);
ostate->vtkglEnable(GL_SCISSOR_TEST);
size_t nBlocks = extents.size();
for (size_t e=0; e<nBlocks; ++e)
{
......@@ -307,10 +307,10 @@ public:
unsigned int extSize[2];
ext.Size(extSize);
ostate->glScissor(ext[0], ext[2], extSize[0], extSize[1]);
ostate->glClear(GL_COLOR_BUFFER_BIT);
ostate->vtkglScissor(ext[0], ext[2], extSize[0], extSize[1]);
ostate->vtkglClear(GL_COLOR_BUFFER_BIT);
}
ostate->glDisable(GL_SCISSOR_TEST);
ostate->vtkglDisable(GL_SCISSOR_TEST);
// detach
// detach
fbo->RemoveTexColorAttachments(GL_DRAW_FRAMEBUFFER, num);
......@@ -334,8 +334,8 @@ public:
// clear the parts of the screen which we will modify
// initially mask all fragments
ostate->glClearColor(0.0, 1.0, 0.0, 0.0);
ostate->glEnable(GL_SCISSOR_TEST);
ostate->vtkglClearColor(0.0, 1.0, 0.0, 0.0);
ostate->vtkglEnable(GL_SCISSOR_TEST);
size_t nBlocks = extents.size();
for (size_t e=0; e<nBlocks; ++e)
{
......@@ -351,10 +351,10 @@ public:
unsigned int extSize[2];
ext.Size(extSize);
ostate->glScissor(ext[0], ext[2], extSize[0], extSize[1]);
ostate->glClear(GL_COLOR_BUFFER_BIT);
ostate->vtkglScissor(ext[0], ext[2], extSize[0], extSize[1]);
ostate->vtkglClear(GL_COLOR_BUFFER_BIT);
}
ostate->glDisable(GL_SCISSOR_TEST);
ostate->vtkglDisable(GL_SCISSOR_TEST);
// detach
fbo->RemoveTexColorAttachments(GL_DRAW_FRAMEBUFFER, 1);
fbo->DeactivateDrawBuffers();
......@@ -1548,9 +1548,9 @@ vtkTextureObject *vtkLineIntegralConvolution2D::Execute(
this->VTShader->Program->SetUniformi("texVectors", bufs.GetVectorTextureUnit());
vtkOpenGLCheckErrorMacro("failed");
// essential to initialize the entire buffer
ostate->glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
ostate->vtkglClearColor(0.0f, 0.0f, 0.0f, 0.0f);
vtkOpenGLCheckErrorMacro("failed");
ostate->glClear(GL_COLOR_BUFFER_BIT);
ostate->vtkglClear(GL_COLOR_BUFFER_BIT);
vtkOpenGLCheckErrorMacro("failed");
size_t nVectorExtents = vectorExtents.size();
for (size_t q=0; q<nVectorExtents; ++q)
......
......@@ -205,11 +205,11 @@ void vtkSurfaceLICInterface::PrepareForGeometry()
// clear internal color and depth buffers
// the LIC'er requires *all* fragments in the vector
// texture to be initialized to 0
ostate->glDisable(GL_BLEND);
ostate->glEnable(GL_DEPTH_TEST);
ostate->glDisable(GL_SCISSOR_TEST);
ostate->glClearColor(0.0, 0.0, 0.0, 0.0);
ostate->glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
ostate->vtkglDisable(GL_BLEND);
ostate->vtkglEnable(GL_DEPTH_TEST);
ostate->vtkglDisable(GL_SCISSOR_TEST);
ostate->vtkglClearColor(0.0, 0.0, 0.0, 0.0);
ostate->vtkglClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
}
void vtkSurfaceLICInterface::CompletedGeometry()
......@@ -514,8 +514,8 @@ void vtkSurfaceLICInterface::CombineColorsAndLIC()
vtkCheckFrameBufferStatusMacro(GL_FRAMEBUFFER);
// clear the parts of the screen which we will modify
ostate->glEnable(GL_SCISSOR_TEST);
ostate->glClearColor(0.0, 0.0, 0.0, 0.0);
ostate->vtkglEnable(GL_SCISSOR_TEST);
ostate->vtkglClearColor(0.0, 0.0, 0.0, 0.0);
size_t nBlocks = this->Internals->BlockExts.size();
for (size_t e=0; e<nBlocks; ++e)
{
......@@ -526,10 +526,10 @@ void vtkSurfaceLICInterface::CombineColorsAndLIC()
unsigned int extSize[2];
ext.Size(extSize);
ostate->glScissor(ext[0], ext[2], extSize[0], extSize[1]);
ostate->glClear(GL_COLOR_BUFFER_BIT);
ostate->vtkglScissor(ext[0], ext[2], extSize[0], extSize[1]);
ostate->vtkglClear(GL_COLOR_BUFFER_BIT);
}
ostate->glDisable(GL_SCISSOR_TEST);
ostate->vtkglDisable(GL_SCISSOR_TEST);
this->Internals->VectorImage->Activate();
this->Internals->GeometryImage->Activate();
......@@ -679,15 +679,15 @@ void vtkSurfaceLICInterface::CopyToScreen()
glDrawBuffer(this->PrevDrawBuf);
ostate->glDisable(GL_BLEND);
ostate->glDisable(GL_SCISSOR_TEST);
ostate->glEnable(GL_DEPTH_TEST);
ostate->vtkglDisable(GL_BLEND);
ostate->vtkglDisable(GL_SCISSOR_TEST);
ostate->vtkglEnable(GL_DEPTH_TEST);
// Viewport transformation for 1:1 'pixel=texel=data' mapping.
// Note this is not enough for 1:1 mapping, because depending on the
// primitive displayed (point,line,polygon), the rasterization rules
// are different.
ostate->glViewport(0, 0, this->Internals->Viewsize[0],
ostate->vtkglViewport(0, 0, this->Internals->Viewsize[0],
this->Internals->Viewsize[1]);
this->Internals->DepthImage->Activate();
......
......@@ -129,9 +129,9 @@ void vtkCameraPass::Render(const vtkRenderState *s)
vtkOpenGLState::ScopedglScissor ssaver(ostate);
vtkOpenGLState::ScopedglEnableDisable stsaver(ostate, GL_SCISSOR_TEST);
ostate->glViewport(lowerLeft[0], lowerLeft[1], usize, vsize);
ostate->glEnable( GL_SCISSOR_TEST );
ostate->glScissor(lowerLeft[0], lowerLeft[1], usize, vsize);
ostate->vtkglViewport(lowerLeft[0], lowerLeft[1], usize, vsize);
ostate->vtkglEnable( GL_SCISSOR_TEST );
ostate->vtkglScissor(lowerLeft[0], lowerLeft[1], usize, vsize);
if ((ren->GetRenderWindow())->GetErase() && ren->GetErase()
&& !ren->GetIsPicking())
......
......@@ -50,9 +50,9 @@ void vtkClearRGBPass::Render(const vtkRenderState *s)
vtkOpenGLState *ostate =
static_cast<vtkOpenGLRenderer*>(s->GetRenderer())->GetState();
ostate->glClearColor( static_cast<GLclampf>(this->Background[0]),
ostate->vtkglClearColor( static_cast<GLclampf>(this->Background[0]),
static_cast<GLclampf>(this->Background[1]),
static_cast<GLclampf>(this->Background[2]),
static_cast<GLclampf>(0.0));
ostate->glClear(GL_COLOR_BUFFER_BIT);
ostate->vtkglClear(GL_COLOR_BUFFER_BIT);
}
......@@ -19,6 +19,7 @@
#include "vtkOpenGLState.h"
#include "vtkRenderState.h"
#include "vtkOpenGLRenderer.h"
#include "vtk_glew.h"
vtkStandardNewMacro(vtkClearZPass);
......@@ -51,7 +52,7 @@ void vtkClearZPass::Render(const vtkRenderState *s)
vtkOpenGLState *ostate =
static_cast<vtkOpenGLRenderer *>(s->GetRenderer())->GetState();
ostate->glDepthMask(GL_TRUE);
ostate->glClearDepth(this->Depth);
ostate->glClear(GL_DEPTH_BUFFER_BIT);
ostate->vtkglDepthMask(GL_TRUE);
ostate->vtkglClearDepth(this->Depth);
ostate->vtkglClear(GL_DEPTH_BUFFER_BIT);
}
......@@ -183,8 +183,8 @@ void vtkDepthOfFieldPass::Render(const vtkRenderState *s)
return;
}
renWin->GetState()->glDisable(GL_BLEND);
renWin->GetState()->glDisable(GL_DEPTH_TEST);
renWin->GetState()->vtkglDisable(GL_BLEND);
renWin->GetState()->vtkglDisable(GL_DEPTH_TEST);
this->Pass1->Activate();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
......
......@@ -276,7 +276,7 @@ void vtkDepthPeelingPass::BlendIntermediatePeels(
this->IntermediateBlend->Program->SetUniformi(
"lastpass", done ? 1 : 0);
this->State->glDisable(GL_DEPTH_TEST);
this->State->vtkglDisable(GL_DEPTH_TEST);
this->Framebuffer->AddColorAttachment(
this->Framebuffer->GetBothMode(), 0,
......@@ -321,13 +321,13 @@ void vtkDepthPeelingPass::BlendFinalPeel(vtkOpenGLRenderWindow *renWin)
this->ColorDrawCount++;
// blend in OpaqueRGBA
this->State->glEnable(GL_DEPTH_TEST);
this->State->glDepthFunc( GL_ALWAYS );
this->State->vtkglEnable(GL_DEPTH_TEST);
this->State->vtkglDepthFunc( GL_ALWAYS );
// do we need to set the viewport
this->FinalBlend->Render();
}
this->State->glDepthFunc( GL_LEQUAL );
this->State->vtkglDepthFunc( GL_LEQUAL );
}
......@@ -472,29 +472,29 @@ void vtkDepthPeelingPass::Render(const vtkRenderState *s)
this->Framebuffer->GetBothMode(), 0,
this->TranslucentRGBATexture[0]);
this->State->glViewport(0, 0,
this->State->vtkglViewport(0, 0,
this->ViewportWidth, this->ViewportHeight);
bool saveScissorTestState = this->State->GetEnumState(GL_SCISSOR_TEST);
this->State->glDisable(GL_SCISSOR_TEST);
this->State->vtkglDisable(GL_SCISSOR_TEST);
this->State->glClearDepth(static_cast<GLclampf>(0.0));
this->State->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
this->State->vtkglClearDepth(static_cast<GLclampf>(0.0));
this->State->vtkglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
this->State->glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
this->State->glClearColor(0.0,0.0,0.0,0.0); // always clear to black
this->State->glClearDepth(static_cast<GLclampf>(1.0));
this->State->vtkglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
this->State->vtkglClearColor(0.0,0.0,0.0,0.0); // always clear to black
this->State->vtkglClearDepth(static_cast<GLclampf>(1.0));
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
this->Framebuffer->AddDepthAttachment(
this->Framebuffer->GetBothMode(),
this->TranslucentZTexture[1]);
this->State->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
this->State->vtkglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
#ifdef GL_MULTISAMPLE
bool multiSampleStatus = this->State->GetEnumState(GL_MULTISAMPLE);
this->State->glDisable(GL_MULTISAMPLE);
this->State->vtkglDisable(GL_MULTISAMPLE);
#endif
this->State->glDisable(GL_BLEND);
this->State->vtkglDisable(GL_BLEND);
this->TranslucentZTexture[0]->Activate();
this->OpaqueZTexture->Activate();
......@@ -536,11 +536,11 @@ void vtkDepthPeelingPass::Render(const vtkRenderState *s)
GLuint nbPixels = threshold + 1;
this->PeelCount = 0;
this->ColorDrawCount = 0;
this->State->glDepthFunc( GL_LEQUAL );
this->State->vtkglDepthFunc( GL_LEQUAL );
while(!done)
{
this->State->glDepthMask(GL_TRUE);
this->State->glEnable(GL_DEPTH_TEST);
this->State->vtkglDepthMask(GL_TRUE);
this->State->vtkglEnable(GL_DEPTH_TEST);
this->Framebuffer->AddColorAttachment(
this->Framebuffer->GetBothMode(), 0,
......@@ -548,7 +548,7 @@ void vtkDepthPeelingPass::Render(const vtkRenderState *s)
this->ColorDrawCount++;
// clear the zbuffer and color buffers
this->State->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
this->State->vtkglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// render the translucent geometry
#if GL_ES_VERSION_3_0 != 1
......@@ -564,12 +564,12 @@ void vtkDepthPeelingPass::Render(const vtkRenderState *s)
done = true;
// if so we do this last render using alpha blending for all
// the stuff that is left
this->State->glEnable(GL_BLEND);
this->State->glDepthFunc( GL_ALWAYS );
this->State->vtkglEnable(GL_BLEND);
this->State->vtkglDepthFunc( GL_ALWAYS );
}
this->TranslucentPass->Render(s);
this->State->glDepthFunc( GL_LEQUAL );
this->State->glDisable(GL_BLEND);
this->State->vtkglDepthFunc( GL_LEQUAL );
this->State->vtkglDisable(GL_BLEND);
#if GL_ES_VERSION_3_0 != 1
glEndQuery(GL_SAMPLES_PASSED);
......@@ -623,15 +623,15 @@ void vtkDepthPeelingPass::Render(const vtkRenderState *s)
// Restore the original viewport and scissor test settings
this->State->glViewport(this->ViewportX, this->ViewportY,
this->State->vtkglViewport(this->ViewportX, this->ViewportY,
this->ViewportWidth, this->ViewportHeight);
if (saveScissorTestState)
{
this->State->glEnable(GL_SCISSOR_TEST);
this->State->vtkglEnable(GL_SCISSOR_TEST);
}
else
{
this->State->glDisable(GL_SCISSOR_TEST);
this->State->vtkglDisable(GL_SCISSOR_TEST);
}
//blit if we drew something
......@@ -658,7 +658,7 @@ void vtkDepthPeelingPass::Render(const vtkRenderState *s)
#ifdef GL_MULTISAMPLE
if(multiSampleStatus)
{
this->State->glEnable(GL_MULTISAMPLE);
this->State->vtkglEnable(GL_MULTISAMPLE);
}
#endif
......@@ -672,7 +672,7 @@ void vtkDepthPeelingPass::Render(const vtkRenderState *s)
this->TranslucentZTexture[1]->Deactivate();
// restore blending
this->State->glEnable(GL_BLEND);
this->State->vtkglEnable(GL_BLEND);
this->PostRender(s);
for (int j = 0; j < numProps; ++j)
......
......@@ -626,14 +626,14 @@ bool vtkEDLShading::EDLCompose(const vtkRenderState *,
// DRAW CONTEXT - prepare blitting
//
// Prepare blitting
ostate->glClearColor(1., 1., 1., 1.);
ostate->glClearDepth(1.0);
ostate->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
ostate->vtkglClearColor(1., 1., 1., 1.);
ostate->vtkglClearDepth(1.0);
ostate->vtkglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// IMPORTANT since we enable depth writing hereafter
ostate->glDisable(GL_BLEND);
ostate->glEnable(GL_DEPTH_TEST);
ostate->vtkglDisable(GL_BLEND);
ostate->vtkglEnable(GL_DEPTH_TEST);
// IMPORTANT : so that depth information is propagated
ostate->glDisable(GL_SCISSOR_TEST);
ostate->vtkglDisable(GL_SCISSOR_TEST);
int blitSize[2] = { this->W - 1 - 2 * this->ExtraPixels,
this->H - 1 - 2 * this->ExtraPixels };
......
......@@ -158,9 +158,9 @@ void vtkFramebufferPass::Render(const vtkRenderState *s)
this->FrameBufferObject->Bind(
this->FrameBufferObject->GetReadMode());
ostate->glViewport(this->ViewportX, this->ViewportY,
ostate->vtkglViewport(this->ViewportX, this->ViewportY,
this->ViewportWidth, this->ViewportHeight);
ostate->glScissor(this->ViewportX, this->ViewportY,
ostate->vtkglScissor(this->ViewportX, this->ViewportY,
this->ViewportWidth, this->ViewportHeight);
glBlitFramebuffer(
......
......@@ -278,8 +278,8 @@ void vtkGaussianBlurPass::Render(const vtkRenderState *s)
glFinish();
#endif
ostate->glDisable(GL_BLEND);
ostate->glDisable(GL_DEPTH_TEST);
ostate->vtkglDisable(GL_BLEND);
ostate->vtkglDisable(GL_DEPTH_TEST);
this->FrameBufferObject->RenderQuad(0,w-1,0,h-1,
this->BlurProgram->Program, this->BlurProgram->VAO);
......
......@@ -98,14 +98,14 @@ void vtkHiddenLineRemovalPass::Render(const vtkRenderState *s)
// Draw the wireframe props as surfaces into the depth buffer only:
annotate("Rendering wireframe prop surfaces.");
this->SetRepresentation(wireframeProps, VTK_SURFACE);
ostate->glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
ostate->vtkglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
this->RenderProps(wireframeProps, vp);
vtkOpenGLStaticCheckErrorMacro("Error after wireframe surface rendering.");
// Now draw the wireframes as normal:
annotate("Rendering wireframes.");
this->SetRepresentation(wireframeProps, VTK_WIREFRAME);
ostate->glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
ostate->vtkglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
this->NumberOfRenderedProps = this->RenderProps(wireframeProps, vp);
vtkOpenGLStaticCheckErrorMacro("Error after wireframe rendering.");
......
......@@ -22,6 +22,7 @@
#include "vtkTextureObject.h"
#include "vtkOpenGLRenderWindow.h"
#include "vtkOpenGLState.h"
#include "vtk_glew.h"
// to be able to dump intermediate passes into png files for debugging.
// only for vtkImageProcessingPass developers.
......@@ -166,11 +167,11 @@ void vtkImageProcessingPass::RenderDelegate(const vtkRenderState *s,
fbo->AddDepthAttachment(fbo->GetBothMode());
fbo->StartNonOrtho(newWidth,newHeight);
ostate->glViewport(0, 0, newWidth, newHeight);
ostate->glScissor(0, 0, newWidth, newHeight);
ostate->vtkglViewport(0, 0, newWidth, newHeight);
ostate->vtkglScissor(0, 0, newWidth, newHeight);
// 2. Delegate render in FBO
ostate->glEnable(GL_DEPTH_TEST);
ostate->vtkglEnable(GL_DEPTH_TEST);
this->DelegatePass->Render(&s2);
this->NumberOfRenderedProps+=
this->DelegatePass->GetNumberOfRenderedProps();
......
......@@ -64,7 +64,7 @@ void vtkOpenGLActor::Render(vtkRenderer *ren, vtkMapper *mapper)
bool opaque = (this->GetIsOpaque() != 0);
if (opaque)
{
ostate->glDepthMask(GL_TRUE);
ostate->vtkglDepthMask(GL_TRUE);
}
else
{
......@@ -72,7 +72,7 @@ void vtkOpenGLActor::Render(vtkRenderer *ren, vtkMapper *mapper)
bool picking = (ren->GetRenderWindow()->GetIsPicking() || selector != nullptr);
if (picking)
{
ostate->glDepthMask(GL_TRUE);
ostate->vtkglDepthMask(GL_TRUE);
}
else
{
......@@ -84,10 +84,10 @@ void vtkOpenGLActor::Render(vtkRenderer *ren, vtkMapper *mapper)
switch (maskoverride)
{
case 0:
ostate->glDepthMask(GL_FALSE);
ostate->vtkglDepthMask(GL_FALSE);
break;
case 1:
ostate->glDepthMask(GL_TRUE);
ostate->vtkglDepthMask(GL_TRUE);
break;
default:
// Do nothing.
......@@ -96,7 +96,7 @@ void vtkOpenGLActor::Render(vtkRenderer *ren, vtkMapper *mapper)
}
else
{
ostate->glDepthMask(GL_FALSE); // transparency with alpha blending
ostate->vtkglDepthMask(GL_FALSE); // transparency with alpha blending
}
}
}
......@@ -106,7 +106,7 @@ void vtkOpenGLActor::Render(vtkRenderer *ren, vtkMapper *mapper)
if (!opaque)
{
ostate->glDepthMask(GL_TRUE);
ostate->vtkglDepthMask(GL_TRUE);
}
vtkOpenGLCheckErrorMacro("failed after Render");
......
......@@ -59,17 +59,17 @@ void vtkOpenGLCamera::Render(vtkRenderer *ren)
this->Stereo = (ren->GetRenderWindow())->GetStereoRender();
ren->GetTiledSizeAndOrigin(&usize, &vsize, lowerLeft, lowerLeft+1);
ostate->glViewport(lowerLeft[0], lowerLeft[1], usize, vsize);
ostate->glEnable(GL_SCISSOR_TEST);
ostate->vtkglViewport(lowerLeft[0], lowerLeft[1], usize, vsize);
ostate->vtkglEnable(GL_SCISSOR_TEST);
if (this->UseScissor)
{
ostate->glScissor(this->ScissorRect.GetX(),this->ScissorRect.GetY(),
ostate->vtkglScissor(this->ScissorRect.GetX(),this->ScissorRect.GetY(),
this->ScissorRect.GetWidth(), this->ScissorRect.GetHeight());
this->UseScissor = false;
}
else
{
ostate->glScissor(lowerLeft[0], lowerLeft[1], usize, vsize);
ostate->vtkglScissor(lowerLeft[0], lowerLeft[1], usize, vsize);
}
if ((ren->GetRenderWindow())->GetErase() && ren->GetErase()
......@@ -92,17 +92,17 @@ void vtkOpenGLCamera::UpdateViewport(vtkRenderer *ren)
int usize, vsize;
ren->GetTiledSizeAndOrigin(&usize, &vsize, lowerLeft, lowerLeft+1);
ostate->glViewport(lowerLeft[0], lowerLeft[1], usize, vsize);
ostate->glEnable(GL_SCISSOR_TEST);
ostate->vtkglViewport(lowerLeft[0], lowerLeft[1], usize, vsize);
ostate->vtkglEnable(GL_SCISSOR_TEST);
if (this->UseScissor)
{
ostate->glScissor(this->ScissorRect.GetX(),this->ScissorRect.GetY(),
ostate->vtkglScissor(this->ScissorRect.GetX(),this->ScissorRect.GetY(),
this->ScissorRect.GetWidth(), this->ScissorRect.GetHeight());
this->UseScissor = false;
}
else
{
ostate->glScissor(lowerLeft[0], lowerLeft[1], usize, vsize);
ostate->vtkglScissor(lowerLeft[0], lowerLeft[1], usize, vsize);
}
vtkOpenGLCheckErrorMacro("failed after UpdateViewport");
......
......@@ -225,8 +225,8 @@ void vtkOpenGLFXAAFilter::Prepare()
this->BlendState = ostate->GetEnumState(GL_BLEND);
this->DepthTestState = ostate->GetEnumState(GL_DEPTH_TEST);
ostate->glDisable(GL_BLEND);
ostate->glDisable(GL_DEPTH_TEST);
ostate->vtkglDisable(GL_BLEND);
ostate->vtkglDisable(GL_DEPTH_TEST);
vtkOpenGLCheckErrorMacro("Error after saving GL state.");
}
......@@ -379,11 +379,11 @@ void vtkOpenGLFXAAFilter::Finalize()
vtkOpenGLState *ostate = this->Renderer->GetState();