summaryrefslogtreecommitdiff
path: root/vcl/opengl/gdiimpl.cxx
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2016-01-01 17:45:06 +0000
committerMichael Meeks <michael.meeks@collabora.com>2016-01-02 17:35:19 +0000
commit3723c3e0b20982ab46d4c04a342af22e88f42fa0 (patch)
tree0ec1ffdf15135b8c89dadf875ee4d60af3d3eeb2 /vcl/opengl/gdiimpl.cxx
parent45c8bbe9303094b50035967846196cf3b7c72ea6 (diff)
vcl: opengl - ensure we have the right GL context for rendering.
Also significantly simplify, and remove paranoid ramblings from the flushing code. Change-Id: Ie7cc742caac290d77ac931c54cc4fe777a7872de
Diffstat (limited to 'vcl/opengl/gdiimpl.cxx')
-rw-r--r--vcl/opengl/gdiimpl.cxx48
1 files changed, 14 insertions, 34 deletions
diff --git a/vcl/opengl/gdiimpl.cxx b/vcl/opengl/gdiimpl.cxx
index 539ae7603efb..56da7c18d5fb 100644
--- a/vcl/opengl/gdiimpl.cxx
+++ b/vcl/opengl/gdiimpl.cxx
@@ -2038,8 +2038,10 @@ void OpenGLSalGraphicsImpl::doFlush()
if( !mpWindowContext.is() )
{
- VCL_GL_INFO( "late creation of window context" );
+ // ensure everything is released from the old context.
+ OpenGLContext::clearCurrent();
mpWindowContext = CreateWinContext();
+ VCL_GL_INFO( "late creation of window context" );
}
assert( mpWindowContext.is() );
@@ -2048,17 +2050,9 @@ void OpenGLSalGraphicsImpl::doFlush()
mpWindowContext->makeCurrent();
CHECK_GL_ERROR();
- VCL_GL_INFO( "flushAndSwap - acquire default frame buffer" );
+ VCL_GL_INFO( "flushAndSwap - acquire default framebuffer" );
mpWindowContext->AcquireDefaultFramebuffer();
- glBindFramebuffer( GL_FRAMEBUFFER, 0 ); // FIXME: paranoid double check.
- CHECK_GL_ERROR();
-
- VCL_GL_INFO( "flushAndSwap - acquired default frame buffer" );
-
- glDisable( GL_SCISSOR_TEST ); // FIXME: paranoia ...
- CHECK_GL_ERROR();
- glDisable( GL_STENCIL_TEST ); // FIXME: paranoia ...
CHECK_GL_ERROR();
glViewport( 0, 0, GetWidth(), GetHeight() );
@@ -2073,8 +2067,6 @@ void OpenGLSalGraphicsImpl::doFlush()
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT );
CHECK_GL_ERROR();
- SalTwoRect aPosAry( 0, 0, maOffscreenTex.GetWidth(), maOffscreenTex.GetHeight(),
- 0, 0, maOffscreenTex.GetWidth(), maOffscreenTex.GetHeight() );
VCL_GL_INFO( "Texture height " << maOffscreenTex.GetHeight() << " vs. window height " << GetHeight() );
OpenGLProgram *pProgram =
@@ -2083,41 +2075,29 @@ void OpenGLSalGraphicsImpl::doFlush()
VCL_GL_INFO( "Can't compile simple copying shader !" );
else
{
- pProgram->Use(); // FIXME: paranoia ...
- VCL_GL_INFO( "done paranoid re-use." );
pProgram->SetTexture( "sampler", maOffscreenTex );
- maOffscreenTex.Bind(); // FIXME: paranoia ...
- VCL_GL_INFO( "bound bits etc." );
+ SalTwoRect aPosAry( 0, 0, maOffscreenTex.GetWidth(), maOffscreenTex.GetHeight(),
+ 0, 0, maOffscreenTex.GetWidth(), maOffscreenTex.GetHeight() );
GLfloat aTexCoord[8];
maOffscreenTex.GetCoord( aTexCoord, aPosAry );
pProgram->SetTextureCoord( aTexCoord );
- long nX1( aPosAry.mnDestX );
- long nY1( aPosAry.mnDestY );
- long nX2( nX1 + aPosAry.mnDestWidth );
- long nY2( nY1 + aPosAry.mnDestHeight );
- const SalPoint aPoints[] = { { nX1, nY2 }, { nX1, nY1 },
- { nX2, nY1 }, { nX2, nY2 }};
-
- sal_uInt32 nPoints = 4;
- std::vector<GLfloat> aVertices(nPoints * 2);
- sal_uInt32 i, j;
-
- for( i = 0, j = 0; i < nPoints; i++, j += 2 )
- {
- aVertices[j] = GLfloat(aPoints[i].mnX);
- aVertices[j+1] = GLfloat(aPoints[i].mnY);
- }
+ GLfloat fWidth( maOffscreenTex.GetWidth() );
+ GLfloat fHeight( maOffscreenTex.GetHeight() );
+ const GLfloat aVertices[] = { 0, fHeight,
+ 0, 0,
+ fWidth, 0,
+ fWidth, fHeight };
pProgram->ApplyMatrix(GetWidth(), GetHeight(), 0.0);
pProgram->SetVertices( &aVertices[0] );
- glDrawArrays( GL_TRIANGLE_FAN, 0, nPoints );
+ glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
pProgram->Clean();
- glBindTexture( GL_TEXTURE_2D, 0 );
+ maOffscreenTex.Unbind();
static bool bNoSwap = getenv("SAL_GL_NO_SWAP");
if (!bNoSwap)