Commit 7bec814a authored by Matt Clarkson's avatar Matt Clarkson

Fixed viewport restore

parent 80a81e03
......@@ -576,6 +576,7 @@ void VividRenderer::renderFrontToBackPeeling(const RenderQueue* render_queue, Ca
camera->viewport()->setScissorEnabled( false );
camera->viewport()->setClearFlags( CF_CLEAR_COLOR_DEPTH );
camera->viewport()->activate();
if ( mVividRendering->backgroundImageEnabled() ) {
renderBackgroundImage( camera );
}
......@@ -586,14 +587,13 @@ void VividRenderer::renderFrontToBackPeeling(const RenderQueue* render_queue, Ca
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
mShaderFrontFinal->useProgram();
bindTexture( mShaderFrontFinal.get(), GL_TEXTURE_RECTANGLE, "ColorTex", mFrontColorBlenderTexId, Vivid::TextureUnit0 );
bindTexture( mShaderFrontFinal.get(), GL_TEXTURE_RECTANGLE, "vl_Vivid.stencil.texture", mStencilTexture->handle(), Vivid::TextureUnit1 );
mShaderFrontFinal->applyUniformSet(); VL_CHECK_OGL();
drawFullScreenQuad();
// 2D Outlilnes
// 2D Outlines
render2DOutlines( render_queue, camera, 0 );
......@@ -1094,6 +1094,7 @@ const RenderQueue* VividRenderer::render(const RenderQueue* render_queue, Camera
//-------------------------------------------------------------------------------------------------
void VividRenderer::renderBackgroundImage( Camera* camera ) {
class SaveStates {
GLint mViewport[4];
GLint mCurrentProgram;
GLboolean mDepthMask;
GLboolean mBlendOn;
......@@ -1115,6 +1116,8 @@ void VividRenderer::renderBackgroundImage( Camera* camera ) {
glMatrixMode( GL_PROJECTION );
glPushMatrix();
glGetIntegerv( GL_VIEWPORT, mViewport );
glGetIntegerv( GL_CURRENT_PROGRAM, &mCurrentProgram ); VL_CHECK_OGL();
glGetBooleanv( GL_DEPTH_WRITEMASK, &mDepthMask ); VL_CHECK_OGL();
mBlendOn = glIsEnabled( GL_BLEND );
......@@ -1135,6 +1138,8 @@ void VividRenderer::renderBackgroundImage( Camera* camera ) {
glMatrixMode( GL_PROJECTION );
glPopMatrix();
glViewport( mViewport[0], mViewport[1], mViewport[2], mViewport[3] );
glUseProgram( mCurrentProgram );
glDepthMask( mDepthMask );
enable( GL_BLEND, mBlendOn );
......
Markdown is supported
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