Kaydet (Commit) da11e337 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Check for OpenGL errors right where an error might be generated

CHECK_GL_ERROR() is now zero-cost in a production build, so no reason
to avoid it.

Don't check for OpenGL errors after glX or wgl calls. They don't
generate OpenGL errors but use the X and Win32 error mechanisms, as
far as I see.

Change-Id: I8f97ef434cbdc89d6e345a247456cfc4a1a82bb6
üst e1d88a57
...@@ -22,12 +22,14 @@ OpenGLFramebuffer::OpenGLFramebuffer() : ...@@ -22,12 +22,14 @@ OpenGLFramebuffer::OpenGLFramebuffer() :
mpNextFramebuffer( nullptr ) mpNextFramebuffer( nullptr )
{ {
glGenFramebuffers( 1, &mnId ); glGenFramebuffers( 1, &mnId );
CHECK_GL_ERROR();
VCL_GL_INFO( "vcl.opengl", "Created framebuffer " << (int)mnId ); VCL_GL_INFO( "vcl.opengl", "Created framebuffer " << (int)mnId );
} }
OpenGLFramebuffer::~OpenGLFramebuffer() OpenGLFramebuffer::~OpenGLFramebuffer()
{ {
glDeleteFramebuffers( 1, &mnId ); glDeleteFramebuffers( 1, &mnId );
CHECK_GL_ERROR();
} }
void OpenGLFramebuffer::Bind() void OpenGLFramebuffer::Bind()
...@@ -40,8 +42,8 @@ void OpenGLFramebuffer::Bind() ...@@ -40,8 +42,8 @@ void OpenGLFramebuffer::Bind()
void OpenGLFramebuffer::Unbind() void OpenGLFramebuffer::Unbind()
{ {
glBindFramebuffer( GL_FRAMEBUFFER, 0 ); glBindFramebuffer( GL_FRAMEBUFFER, 0 );
VCL_GL_INFO( "vcl.opengl", "Binding default framebuffer" );
CHECK_GL_ERROR(); CHECK_GL_ERROR();
VCL_GL_INFO( "vcl.opengl", "Binding default framebuffer" );
} }
bool OpenGLFramebuffer::IsFree() const bool OpenGLFramebuffer::IsFree() const
...@@ -69,18 +71,19 @@ void OpenGLFramebuffer::AttachTexture( const OpenGLTexture& rTexture ) ...@@ -69,18 +71,19 @@ void OpenGLFramebuffer::AttachTexture( const OpenGLTexture& rTexture )
mnWidth = rTexture.GetWidth(); mnWidth = rTexture.GetWidth();
mnHeight = rTexture.GetHeight(); mnHeight = rTexture.GetHeight();
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mnAttachedTexture, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mnAttachedTexture, 0);
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) CHECK_GL_ERROR();
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
CHECK_GL_ERROR();
if (status != GL_FRAMEBUFFER_COMPLETE)
{ {
SAL_WARN("vcl.opengl", "Framebuffer incomplete"); SAL_WARN("vcl.opengl", "Framebuffer incomplete");
} }
CHECK_GL_ERROR();
} }
void OpenGLFramebuffer::DetachTexture() void OpenGLFramebuffer::DetachTexture()
{ {
if( mnAttachedTexture != 0 ) if( mnAttachedTexture != 0 )
{ {
CHECK_GL_ERROR();
mnAttachedTexture = 0; mnAttachedTexture = 0;
glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0 ); glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0 );
CHECK_GL_ERROR(); CHECK_GL_ERROR();
......
...@@ -177,6 +177,7 @@ void OpenGLSalGraphicsImpl::PreDraw() ...@@ -177,6 +177,7 @@ void OpenGLSalGraphicsImpl::PreDraw()
CHECK_GL_ERROR(); CHECK_GL_ERROR();
glViewport( 0, 0, GetWidth(), GetHeight() ); glViewport( 0, 0, GetWidth(), GetHeight() );
CHECK_GL_ERROR();
ImplInitClipRegion(); ImplInitClipRegion();
CHECK_GL_ERROR(); CHECK_GL_ERROR();
...@@ -187,9 +188,15 @@ void OpenGLSalGraphicsImpl::PostDraw() ...@@ -187,9 +188,15 @@ void OpenGLSalGraphicsImpl::PostDraw()
if( !mbOffscreen && mpContext->mnPainting == 0 ) if( !mbOffscreen && mpContext->mnPainting == 0 )
glFlush(); glFlush();
if( mbUseScissor ) if( mbUseScissor )
{
glDisable( GL_SCISSOR_TEST ); glDisable( GL_SCISSOR_TEST );
if( mbUseStencil ) CHECK_GL_ERROR();
}
if( mbUseStencil )
{
glDisable( GL_STENCIL_TEST ); glDisable( GL_STENCIL_TEST );
CHECK_GL_ERROR();
}
if( mpProgram ) if( mpProgram )
{ {
mpProgram->Clean(); mpProgram->Clean();
...@@ -198,8 +205,6 @@ void OpenGLSalGraphicsImpl::PostDraw() ...@@ -198,8 +205,6 @@ void OpenGLSalGraphicsImpl::PostDraw()
mProgramIsSolidColor = false; mProgramIsSolidColor = false;
#endif #endif
} }
CHECK_GL_ERROR();
OpenGLZone::leave(); OpenGLZone::leave();
} }
...@@ -222,12 +227,18 @@ void OpenGLSalGraphicsImpl::freeResources() ...@@ -222,12 +227,18 @@ void OpenGLSalGraphicsImpl::freeResources()
void OpenGLSalGraphicsImpl::ImplSetClipBit( const vcl::Region& rClip, GLuint nMask ) void OpenGLSalGraphicsImpl::ImplSetClipBit( const vcl::Region& rClip, GLuint nMask )
{ {
glEnable( GL_STENCIL_TEST ); glEnable( GL_STENCIL_TEST );
CHECK_GL_ERROR();
glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
CHECK_GL_ERROR();
glStencilMask( nMask ); glStencilMask( nMask );
CHECK_GL_ERROR();
glStencilFunc( GL_NEVER, nMask, 0xFF ); glStencilFunc( GL_NEVER, nMask, 0xFF );
CHECK_GL_ERROR();
glStencilOp( GL_REPLACE, GL_KEEP, GL_KEEP ); glStencilOp( GL_REPLACE, GL_KEEP, GL_KEEP );
CHECK_GL_ERROR();
glClear( GL_STENCIL_BUFFER_BIT ); glClear( GL_STENCIL_BUFFER_BIT );
CHECK_GL_ERROR();
if( UseSolid( MAKE_SALCOLOR( 0xFF, 0xFF, 0xFF ) ) ) if( UseSolid( MAKE_SALCOLOR( 0xFF, 0xFF, 0xFF ) ) )
{ {
if( rClip.getRegionBand() ) if( rClip.getRegionBand() )
...@@ -237,9 +248,10 @@ void OpenGLSalGraphicsImpl::ImplSetClipBit( const vcl::Region& rClip, GLuint nMa ...@@ -237,9 +248,10 @@ void OpenGLSalGraphicsImpl::ImplSetClipBit( const vcl::Region& rClip, GLuint nMa
} }
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
CHECK_GL_ERROR();
glStencilMask( 0x00 ); glStencilMask( 0x00 );
CHECK_GL_ERROR();
glDisable( GL_STENCIL_TEST ); glDisable( GL_STENCIL_TEST );
CHECK_GL_ERROR(); CHECK_GL_ERROR();
} }
...@@ -253,6 +265,7 @@ void OpenGLSalGraphicsImpl::ImplInitClipRegion() ...@@ -253,6 +265,7 @@ void OpenGLSalGraphicsImpl::ImplInitClipRegion()
{ {
Rectangle aRect( maClipRegion.GetBoundRect() ); Rectangle aRect( maClipRegion.GetBoundRect() );
glScissor( aRect.Left(), GetHeight() - aRect.Bottom() - 1, aRect.GetWidth() + 1, aRect.GetHeight() + 1 ); glScissor( aRect.Left(), GetHeight() - aRect.Bottom() - 1, aRect.GetWidth() + 1, aRect.GetHeight() + 1 );
CHECK_GL_ERROR();
} }
else if( !maClipRegion.IsEmpty() ) else if( !maClipRegion.IsEmpty() )
{ {
...@@ -261,14 +274,17 @@ void OpenGLSalGraphicsImpl::ImplInitClipRegion() ...@@ -261,14 +274,17 @@ void OpenGLSalGraphicsImpl::ImplInitClipRegion()
} }
if( mbUseScissor ) if( mbUseScissor )
{
glEnable( GL_SCISSOR_TEST ); glEnable( GL_SCISSOR_TEST );
CHECK_GL_ERROR();
}
if( mbUseStencil ) if( mbUseStencil )
{ {
glStencilFunc( GL_EQUAL, 1, 0x1 ); glStencilFunc( GL_EQUAL, 1, 0x1 );
CHECK_GL_ERROR();
glEnable( GL_STENCIL_TEST ); glEnable( GL_STENCIL_TEST );
CHECK_GL_ERROR();
} }
CHECK_GL_ERROR();
} }
const vcl::Region& OpenGLSalGraphicsImpl::getClipRegion() const const vcl::Region& OpenGLSalGraphicsImpl::getClipRegion() const
...@@ -477,7 +493,6 @@ void OpenGLSalGraphicsImpl::DrawPoint( long nX, long nY ) ...@@ -477,7 +493,6 @@ void OpenGLSalGraphicsImpl::DrawPoint( long nX, long nY )
ApplyProgramMatrices(0.5f); ApplyProgramMatrices(0.5f);
mpProgram->SetVertices( pPoint ); mpProgram->SetVertices( pPoint );
glDrawArrays( GL_POINTS, 0, 1 ); glDrawArrays( GL_POINTS, 0, 1 );
CHECK_GL_ERROR(); CHECK_GL_ERROR();
} }
...@@ -495,7 +510,6 @@ void OpenGLSalGraphicsImpl::DrawLine( double nX1, double nY1, double nX2, double ...@@ -495,7 +510,6 @@ void OpenGLSalGraphicsImpl::DrawLine( double nX1, double nY1, double nX2, double
ApplyProgramMatrices(0.5f); ApplyProgramMatrices(0.5f);
mpProgram->SetVertices( pPoints ); mpProgram->SetVertices( pPoints );
glDrawArrays( GL_LINES, 0, 2 ); glDrawArrays( GL_LINES, 0, 2 );
CHECK_GL_ERROR(); CHECK_GL_ERROR();
} }
...@@ -517,8 +531,6 @@ void OpenGLSalGraphicsImpl::DrawLineAA( double nX1, double nY1, double nX2, doub ...@@ -517,8 +531,6 @@ void OpenGLSalGraphicsImpl::DrawLineAA( double nX1, double nY1, double nX2, doub
return; return;
} }
ImplDrawLineAA( nX1, nY1, nX2, nY2 ); ImplDrawLineAA( nX1, nY1, nX2, nY2 );
CHECK_GL_ERROR();
} }
void OpenGLSalGraphicsImpl::ImplDrawLineAA( double nX1, double nY1, double nX2, double nY2, bool edge ) void OpenGLSalGraphicsImpl::ImplDrawLineAA( double nX1, double nY1, double nX2, double nY2, bool edge )
...@@ -655,7 +667,6 @@ void OpenGLSalGraphicsImpl::ImplDrawLineAA( double nX1, double nY1, double nX2, ...@@ -655,7 +667,6 @@ void OpenGLSalGraphicsImpl::ImplDrawLineAA( double nX1, double nY1, double nX2,
mpProgram->SetTextureCoord( aTexCoord ); mpProgram->SetTextureCoord( aTexCoord );
mpProgram->SetVertices( vertices ); mpProgram->SetVertices( vertices );
glDrawArrays(GL_TRIANGLE_STRIP, 0, 8); glDrawArrays(GL_TRIANGLE_STRIP, 0, 8);
CHECK_GL_ERROR(); CHECK_GL_ERROR();
} }
...@@ -692,6 +703,7 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( sal_uInt32 nPoints, const SalPoin ...@@ -692,6 +703,7 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( sal_uInt32 nPoints, const SalPoin
ApplyProgramMatrices(); ApplyProgramMatrices();
mpProgram->SetVertices( &aVertices[0] ); mpProgram->SetVertices( &aVertices[0] );
glDrawArrays( GL_TRIANGLE_FAN, 0, nPoints ); glDrawArrays( GL_TRIANGLE_FAN, 0, nPoints );
CHECK_GL_ERROR();
if( !blockAA && mrParent.getAntiAliasB2DDraw()) if( !blockAA && mrParent.getAntiAliasB2DDraw())
{ {
...@@ -715,8 +727,6 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( sal_uInt32 nPoints, const SalPoin ...@@ -715,8 +727,6 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( sal_uInt32 nPoints, const SalPoin
UseSolid( lastSolidColor, lastSolidTransparency ); UseSolid( lastSolidColor, lastSolidTransparency );
} }
} }
CHECK_GL_ERROR();
} }
void OpenGLSalGraphicsImpl::DrawConvexPolygon( const tools::Polygon& rPolygon, bool blockAA ) void OpenGLSalGraphicsImpl::DrawConvexPolygon( const tools::Polygon& rPolygon, bool blockAA )
...@@ -737,6 +747,7 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( const tools::Polygon& rPolygon, b ...@@ -737,6 +747,7 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( const tools::Polygon& rPolygon, b
ApplyProgramMatrices(); ApplyProgramMatrices();
mpProgram->SetVertices( &aVertices[0] ); mpProgram->SetVertices( &aVertices[0] );
glDrawArrays( GL_TRIANGLE_FAN, 0, nPoints ); glDrawArrays( GL_TRIANGLE_FAN, 0, nPoints );
CHECK_GL_ERROR();
if( !blockAA && mrParent.getAntiAliasB2DDraw()) if( !blockAA && mrParent.getAntiAliasB2DDraw())
{ {
...@@ -760,8 +771,6 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( const tools::Polygon& rPolygon, b ...@@ -760,8 +771,6 @@ void OpenGLSalGraphicsImpl::DrawConvexPolygon( const tools::Polygon& rPolygon, b
UseSolid( lastSolidColor, lastSolidTransparency ); UseSolid( lastSolidColor, lastSolidTransparency );
} }
} }
CHECK_GL_ERROR();
} }
void OpenGLSalGraphicsImpl::DrawTrapezoid( const basegfx::B2DTrapezoid& trapezoid, bool blockAA ) void OpenGLSalGraphicsImpl::DrawTrapezoid( const basegfx::B2DTrapezoid& trapezoid, bool blockAA )
...@@ -789,6 +798,7 @@ void OpenGLSalGraphicsImpl::DrawTrapezoid( const basegfx::B2DTrapezoid& trapezoi ...@@ -789,6 +798,7 @@ void OpenGLSalGraphicsImpl::DrawTrapezoid( const basegfx::B2DTrapezoid& trapezoi
ApplyProgramMatrices(); ApplyProgramMatrices();
mpProgram->SetVertices( &aVertices[0] ); mpProgram->SetVertices( &aVertices[0] );
glDrawArrays( GL_TRIANGLE_FAN, 0, nPoints ); glDrawArrays( GL_TRIANGLE_FAN, 0, nPoints );
CHECK_GL_ERROR();
if( !blockAA && mrParent.getAntiAliasB2DDraw()) if( !blockAA && mrParent.getAntiAliasB2DDraw())
{ {
...@@ -812,8 +822,6 @@ void OpenGLSalGraphicsImpl::DrawTrapezoid( const basegfx::B2DTrapezoid& trapezoi ...@@ -812,8 +822,6 @@ void OpenGLSalGraphicsImpl::DrawTrapezoid( const basegfx::B2DTrapezoid& trapezoi
UseSolid( lastSolidColor, lastSolidTransparency ); UseSolid( lastSolidColor, lastSolidTransparency );
} }
} }
CHECK_GL_ERROR();
} }
void OpenGLSalGraphicsImpl::DrawRect( long nX, long nY, long nWidth, long nHeight ) void OpenGLSalGraphicsImpl::DrawRect( long nX, long nY, long nWidth, long nHeight )
...@@ -904,7 +912,6 @@ void OpenGLSalGraphicsImpl::DrawRegionBand( const RegionBand& rRegion ) ...@@ -904,7 +912,6 @@ void OpenGLSalGraphicsImpl::DrawRegionBand( const RegionBand& rRegion )
ApplyProgramMatrices(); ApplyProgramMatrices();
mpProgram->SetVertices( &aVertices[0] ); mpProgram->SetVertices( &aVertices[0] );
glDrawArrays( GL_TRIANGLES, 0, aVertices.size() / 2 ); glDrawArrays( GL_TRIANGLES, 0, aVertices.size() / 2 );
CHECK_GL_ERROR(); CHECK_GL_ERROR();
} }
...@@ -1026,9 +1033,8 @@ void OpenGLSalGraphicsImpl::DrawTransformedTexture( ...@@ -1026,9 +1033,8 @@ void OpenGLSalGraphicsImpl::DrawTransformedTexture(
mpProgram->SetTextureCoord( aTexCoord ); mpProgram->SetTextureCoord( aTexCoord );
mpProgram->SetVertices( &aVertices[0] ); mpProgram->SetVertices( &aVertices[0] );
glDrawArrays( GL_TRIANGLE_FAN, 0, 4 ); glDrawArrays( GL_TRIANGLE_FAN, 0, 4 );
mpProgram->Clean();
CHECK_GL_ERROR(); CHECK_GL_ERROR();
mpProgram->Clean();
} }
void OpenGLSalGraphicsImpl::DrawAlphaTexture( OpenGLTexture& rTexture, const SalTwoRect& rPosAry, bool bInverted, bool bPremultiplied ) void OpenGLSalGraphicsImpl::DrawAlphaTexture( OpenGLTexture& rTexture, const SalTwoRect& rPosAry, bool bInverted, bool bPremultiplied )
...@@ -1293,6 +1299,7 @@ void OpenGLSalGraphicsImpl::drawRect( long nX, long nY, long nWidth, long nHeigh ...@@ -1293,6 +1299,7 @@ void OpenGLSalGraphicsImpl::drawRect( long nX, long nY, long nWidth, long nHeigh
ApplyProgramMatrices(0.5f); ApplyProgramMatrices(0.5f);
mpProgram->SetVertices(pPoints); mpProgram->SetVertices(pPoints);
glDrawArrays(GL_LINE_LOOP, 0, 4); glDrawArrays(GL_LINE_LOOP, 0, 4);
CHECK_GL_ERROR();
} }
PostDraw(); PostDraw();
...@@ -1614,9 +1621,9 @@ SalColor OpenGLSalGraphicsImpl::getPixel( long nX, long nY ) ...@@ -1614,9 +1621,9 @@ SalColor OpenGLSalGraphicsImpl::getPixel( long nX, long nY )
PreDraw(); PreDraw();
nY = GetHeight() - nY - 1; nY = GetHeight() - nY - 1;
glReadPixels( nX, nY, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, pixel); glReadPixels( nX, nY, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, pixel);
CHECK_GL_ERROR();
PostDraw(); PostDraw();
CHECK_GL_ERROR();
return MAKE_SALCOLOR( pixel[0], pixel[1], pixel[2] ); return MAKE_SALCOLOR( pixel[0], pixel[1], pixel[2] );
} }
...@@ -1689,9 +1696,12 @@ bool OpenGLSalGraphicsImpl::blendBitmap( ...@@ -1689,9 +1696,12 @@ bool OpenGLSalGraphicsImpl::blendBitmap(
VCL_GL_INFO( "vcl.opengl", "::blendBitmap" ); VCL_GL_INFO( "vcl.opengl", "::blendBitmap" );
PreDraw(); PreDraw();
glEnable( GL_BLEND ); glEnable( GL_BLEND );
CHECK_GL_ERROR();
glBlendFunc( GL_ZERO, GL_SRC_COLOR ); glBlendFunc( GL_ZERO, GL_SRC_COLOR );
CHECK_GL_ERROR();
DrawTexture( rTexture, rPosAry ); DrawTexture( rTexture, rPosAry );
glDisable( GL_BLEND ); glDisable( GL_BLEND );
CHECK_GL_ERROR();
PostDraw(); PostDraw();
return true; return true;
} }
...@@ -1820,12 +1830,16 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly, ...@@ -1820,12 +1830,16 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly,
if( mbUseStencil ) if( mbUseStencil )
{ {
glEnable( GL_STENCIL_TEST ); glEnable( GL_STENCIL_TEST );
CHECK_GL_ERROR();
glStencilFunc( GL_EQUAL, 3, 0xFF ); glStencilFunc( GL_EQUAL, 3, 0xFF );
CHECK_GL_ERROR();
} }
else else
{ {
glEnable( GL_STENCIL_TEST ); glEnable( GL_STENCIL_TEST );
CHECK_GL_ERROR();
glStencilFunc( GL_EQUAL, 2, 0xFF ); glStencilFunc( GL_EQUAL, 2, 0xFF );
CHECK_GL_ERROR();
} }
#endif #endif
...@@ -1854,11 +1868,13 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly, ...@@ -1854,11 +1868,13 @@ bool OpenGLSalGraphicsImpl::drawGradient(const tools::PolyPolygon& rPolyPoly,
#if FIXME_BROKEN_STENCIL_FOR_GRADIENTS #if FIXME_BROKEN_STENCIL_FOR_GRADIENTS
if( !mbUseStencil ) if( !mbUseStencil )
{
glDisable( GL_STENCIL_TEST ); glDisable( GL_STENCIL_TEST );
CHECK_GL_ERROR();
}
#endif #endif
PostDraw(); PostDraw();
CHECK_GL_ERROR();
return true; return true;
} }
......
...@@ -33,7 +33,10 @@ OpenGLProgram::~OpenGLProgram() ...@@ -33,7 +33,10 @@ OpenGLProgram::~OpenGLProgram()
{ {
maUniformLocations.clear(); maUniformLocations.clear();
if( mnId != 0 ) if( mnId != 0 )
{
glDeleteProgram( mnId ); glDeleteProgram( mnId );
CHECK_GL_ERROR();
}
} }
bool OpenGLProgram::Load( const OUString& rVertexShader, bool OpenGLProgram::Load( const OUString& rVertexShader,
...@@ -51,6 +54,7 @@ bool OpenGLProgram::Use() ...@@ -51,6 +54,7 @@ bool OpenGLProgram::Use()
return false; return false;
glUseProgram( mnId ); glUseProgram( mnId );
CHECK_GL_ERROR();
return true; return true;
} }
...@@ -64,6 +68,7 @@ bool OpenGLProgram::Clean() ...@@ -64,6 +68,7 @@ bool OpenGLProgram::Clean()
while( it != maTextures.rend() ) while( it != maTextures.rend() )
{ {
glActiveTexture( GL_TEXTURE0 + nIndex-- ); glActiveTexture( GL_TEXTURE0 + nIndex-- );
CHECK_GL_ERROR();
it->Unbind(); it->Unbind();
++it; ++it;
} }
...@@ -76,7 +81,10 @@ bool OpenGLProgram::Clean() ...@@ -76,7 +81,10 @@ bool OpenGLProgram::Clean()
for( int i = 0; i < 32; i++ ) for( int i = 0; i < 32; i++ )
{ {
if( mnEnabledAttribs & ( 1 << i ) ) if( mnEnabledAttribs & ( 1 << i ) )
{
glDisableVertexAttribArray( i ); glDisableVertexAttribArray( i );
CHECK_GL_ERROR();
}
} }
mnEnabledAttribs = 0; mnEnabledAttribs = 0;
} }
...@@ -86,22 +94,27 @@ bool OpenGLProgram::Clean() ...@@ -86,22 +94,27 @@ bool OpenGLProgram::Clean()
{ {
mbBlending = false; mbBlending = false;
glDisable( GL_BLEND ); glDisable( GL_BLEND );
CHECK_GL_ERROR();
} }
CHECK_GL_ERROR();
return true; return true;
} }
void OpenGLProgram::SetVertexAttrib( GLuint& rAttrib, const OString& rName, const GLvoid* pData ) void OpenGLProgram::SetVertexAttrib( GLuint& rAttrib, const OString& rName, const GLvoid* pData )
{ {
if( rAttrib == SAL_MAX_UINT32 ) if( rAttrib == SAL_MAX_UINT32 )
{
rAttrib = glGetAttribLocation( mnId, rName.getStr() ); rAttrib = glGetAttribLocation( mnId, rName.getStr() );
CHECK_GL_ERROR();
}
if( (mnEnabledAttribs & ( 1 << rAttrib )) == 0 ) if( (mnEnabledAttribs & ( 1 << rAttrib )) == 0 )
{ {
glEnableVertexAttribArray( rAttrib ); glEnableVertexAttribArray( rAttrib );
CHECK_GL_ERROR();
mnEnabledAttribs |= ( 1 << rAttrib ); mnEnabledAttribs |= ( 1 << rAttrib );
} }
glVertexAttribPointer( rAttrib, 2, GL_FLOAT, GL_FALSE, 0, pData ); glVertexAttribPointer( rAttrib, 2, GL_FLOAT, GL_FALSE, 0, pData );
CHECK_GL_ERROR();
} }
void OpenGLProgram::SetVertices( const GLvoid* pData ) void OpenGLProgram::SetVertices( const GLvoid* pData )
...@@ -130,6 +143,7 @@ GLuint OpenGLProgram::GetUniformLocation( const OString& rName ) ...@@ -130,6 +143,7 @@ GLuint OpenGLProgram::GetUniformLocation( const OString& rName )
if( it == maUniformLocations.end() ) if( it == maUniformLocations.end() )
{ {
GLuint nLocation = glGetUniformLocation( mnId, rName.getStr() ); GLuint nLocation = glGetUniformLocation( mnId, rName.getStr() );
CHECK_GL_ERROR();
maUniformLocations[rName] = nLocation; maUniformLocations[rName] = nLocation;
return nLocation; return nLocation;
} }
...@@ -141,30 +155,35 @@ void OpenGLProgram::SetUniform1f( const OString& rName, GLfloat v1 ) ...@@ -141,30 +155,35 @@ void OpenGLProgram::SetUniform1f( const OString& rName, GLfloat v1 )
{ {
GLuint nUniform = GetUniformLocation( rName ); GLuint nUniform = GetUniformLocation( rName );
glUniform1f( nUniform, v1 ); glUniform1f( nUniform, v1 );
CHECK_GL_ERROR();
} }
void OpenGLProgram::SetUniform2f( const OString& rName, GLfloat v1, GLfloat v2 ) void OpenGLProgram::SetUniform2f( const OString& rName, GLfloat v1, GLfloat v2 )
{ {
GLuint nUniform = GetUniformLocation( rName ); GLuint nUniform = GetUniformLocation( rName );
glUniform2f( nUniform, v1, v2 ); glUniform2f( nUniform, v1, v2 );
CHECK_GL_ERROR();
} }
void OpenGLProgram::SetUniform1fv( const OString& rName, GLsizei nCount, GLfloat* aValues ) void OpenGLProgram::SetUniform1fv( const OString& rName, GLsizei nCount, GLfloat* aValues )
{ {
GLuint nUniform = GetUniformLocation( rName ); GLuint nUniform = GetUniformLocation( rName );
glUniform1fv( nUniform, nCount, aValues ); glUniform1fv( nUniform, nCount, aValues );
CHECK_GL_ERROR();
} }
void OpenGLProgram::SetUniform2fv( const OString& rName, GLsizei nCount, GLfloat* aValues ) void OpenGLProgram::SetUniform2fv( const OString& rName, GLsizei nCount, GLfloat* aValues )
{ {
GLuint nUniform = GetUniformLocation( rName ); GLuint nUniform = GetUniformLocation( rName );
glUniform2fv( nUniform, nCount, aValues ); glUniform2fv( nUniform, nCount, aValues );
CHECK_GL_ERROR();
} }
void OpenGLProgram::SetUniform1i( const OString& rName, GLint v1 ) void OpenGLProgram::SetUniform1i( const OString& rName, GLint v1 )
{ {
GLuint nUniform = GetUniformLocation( rName ); GLuint nUniform = GetUniformLocation( rName );
glUniform1i( nUniform, v1 ); glUniform1i( nUniform, v1 );
CHECK_GL_ERROR();
} }
void OpenGLProgram::SetColor( const OString& rName, SalColor nColor, sal_uInt8 nTransparency ) void OpenGLProgram::SetColor( const OString& rName, SalColor nColor, sal_uInt8 nTransparency )
...@@ -175,6 +194,7 @@ void OpenGLProgram::SetColor( const OString& rName, SalColor nColor, sal_uInt8 n ...@@ -175,6 +194,7 @@ void OpenGLProgram::SetColor( const OString& rName, SalColor nColor, sal_uInt8 n
((float) SALCOLOR_GREEN( nColor )) / 255, ((float) SALCOLOR_GREEN( nColor )) / 255,
((float) SALCOLOR_BLUE( nColor )) / 255, ((float) SALCOLOR_BLUE( nColor )) / 255,
(100 - nTransparency) * (1.0 / 100) ); (100 - nTransparency) * (1.0 / 100) );
CHECK_GL_ERROR();
if( nTransparency > 0 ) if( nTransparency > 0 )
SetBlendMode( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); SetBlendMode( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
...@@ -188,6 +208,7 @@ void OpenGLProgram::SetColorf( const OString& rName, SalColor nColor, double fTr ...@@ -188,6 +208,7 @@ void OpenGLProgram::SetColorf( const OString& rName, SalColor nColor, double fTr
((float) SALCOLOR_GREEN( nColor )) / 255, ((float) SALCOLOR_GREEN( nColor )) / 255,
((float) SALCOLOR_BLUE( nColor )) / 255, ((float) SALCOLOR_BLUE( nColor )) / 255,
(1.0f - fTransparency) ); (1.0f - fTransparency) );
CHECK_GL_ERROR();
if( fTransparency > 0.0 ) if( fTransparency > 0.0 )
SetBlendMode( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); SetBlendMode( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
...@@ -201,6 +222,7 @@ void OpenGLProgram::SetColor( const OString& rName, const Color& rColor ) ...@@ -201,6 +222,7 @@ void OpenGLProgram::SetColor( const OString& rName, const Color& rColor )
((float) rColor.GetGreen()) / 255, ((float) rColor.GetGreen()) / 255,
((float) rColor.GetBlue()) / 255, ((float) rColor.GetBlue()) / 255,
1.0f - ((float) rColor.GetTransparency()) / 255 ); 1.0f - ((float) rColor.GetTransparency()) / 255 );
CHECK_GL_ERROR();
if( rColor.GetTransparency() > 0 ) if( rColor.GetTransparency() > 0 )
SetBlendMode( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); SetBlendMode( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
...@@ -214,6 +236,7 @@ void OpenGLProgram::SetColorWithIntensity( const OString& rName, const Color& rC ...@@ -214,6 +236,7 @@ void OpenGLProgram::SetColorWithIntensity( const OString& rName, const Color& rC
((float) rColor.GetGreen()) * nFactor / 25500.0, ((float) rColor.GetGreen()) * nFactor / 25500.0,
((float) rColor.GetBlue()) * nFactor / 25500.0, ((float) rColor.GetBlue()) * nFactor / 25500.0,
1.0f ); 1.0f );
CHECK_GL_ERROR();
} }
void OpenGLProgram::SetTexture( const OString& rName, OpenGLTexture& rTexture ) void OpenGLProgram::SetTexture( const OString& rName, OpenGLTexture& rTexture )
...@@ -222,7 +245,9 @@ void OpenGLProgram::SetTexture( const OString& rName, OpenGLTexture& rTexture ) ...@@ -222,7 +245,9 @@ void OpenGLProgram::SetTexture( const OString& rName, OpenGLTexture& rTexture )
int nIndex = maTextures.size(); int nIndex = maTextures.size();
glUniform1i( nUniform, nIndex ); glUniform1i( nUniform, nIndex );
CHECK_GL_ERROR();
glActiveTexture( GL_TEXTURE0 + nIndex ); glActiveTexture( GL_TEXTURE0 + nIndex );
CHECK_GL_ERROR();
rTexture.Bind(); rTexture.Bind();
maTextures.push_back( rTexture ); maTextures.push_back( rTexture );
} }
...@@ -249,6 +274,7 @@ void OpenGLProgram::SetTransform( ...@@ -249,6 +274,7 @@ void OpenGLProgram::SetTransform(
(float) rNull.getX(), (float) rNull.getY(), 0, 1 }; (float) rNull.getX(), (float) rNull.getY(), 0, 1 };
glm::mat4 mMatrix = glm::make_mat4( aValues ); glm::mat4 mMatrix = glm::make_mat4( aValues );
glUniformMatrix4fv( nUniform, 1, GL_FALSE, glm::value_ptr( mMatrix ) ); glUniformMatrix4fv( nUniform, 1, GL_FALSE, glm::value_ptr( mMatrix ) );
CHECK_GL_ERROR();
} }
void OpenGLProgram::ApplyMatrix(float fWidth, float fHeight, float fPixelOffset) void OpenGLProgram::ApplyMatrix(float fWidth, float fHeight, float fPixelOffset)
...@@ -270,12 +296,15 @@ void OpenGLProgram::ApplyMatrix(float fWidth, float fHeight, float fPixelOffset) ...@@ -270,12 +296,15 @@ void OpenGLProgram::ApplyMatrix(float fWidth, float fHeight, float fPixelOffset)
mMVP = glm::translate(mMVP, glm::vec3(fPixelOffset, fPixelOffset, 0.0f)); mMVP = glm::translate(mMVP, glm::vec3(fPixelOffset, fPixelOffset, 0.0f));
glUniformMatrix4fv(nUniform, 1, GL_FALSE, glm::value_ptr(mMVP)); glUniformMatrix4fv(nUniform, 1, GL_FALSE, glm::value_ptr(mMVP));
CHECK_GL_ERROR();
} }
void OpenGLProgram::SetBlendMode( GLenum nSFactor, GLenum nDFactor ) void OpenGLProgram::SetBlendMode( GLenum nSFactor, GLenum nDFactor )
{ {
glEnable( GL_BLEND ); glEnable( GL_BLEND );
CHECK_GL_ERROR();
glBlendFunc( nSFactor, nDFactor ); glBlendFunc( nSFactor, nDFactor );
CHECK_GL_ERROR();
mbBlending = true; mbBlending = true;
} }
......
...@@ -38,18 +38,26 @@ ImplOpenGLTexture::ImplOpenGLTexture( int nWidth, int nHeight, bool bAllocate ) ...@@ -38,18 +38,26 @@ ImplOpenGLTexture::ImplOpenGLTexture( int nWidth, int nHeight, bool bAllocate )
mnFreeSlots(-1) mnFreeSlots(-1)
{ {
glGenTextures( 1, &mnTexture ); glGenTextures( 1, &mnTexture );
CHECK_GL_ERROR();
glBindTexture( GL_TEXTURE_2D, mnTexture ); glBindTexture( GL_TEXTURE_2D, mnTexture );
CHECK_GL_ERROR();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
CHECK_GL_ERROR();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
CHECK_GL_ERROR();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
CHECK_GL_ERROR();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
CHECK_GL_ERROR();
if( bAllocate ) if( bAllocate )
{
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, nWidth, nHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr ); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, nWidth, nHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr );
CHECK_GL_ERROR();
}
glBindTexture( GL_TEXTURE_2D, 0 ); glBindTexture( GL_TEXTURE_2D, 0 );
CHECK_GL_ERROR();
VCL_GL_INFO( "vcl.opengl", "OpenGLTexture " << mnTexture << " " << nWidth << "x" << nHeight << " allocate" ); VCL_GL_INFO( "vcl.opengl", "OpenGLTexture " << mnTexture << " " << nWidth << "x" << nHeight << " allocate" );
CHECK_GL_ERROR();
} }
// texture with content retrieved from FBO // texture with content retrieved from FBO
...@@ -65,18 +73,23 @@ ImplOpenGLTexture::ImplOpenGLTexture( int nX, int nY, int nWidth, int nHeight ) ...@@ -65,18 +73,23 @@ ImplOpenGLTexture::ImplOpenGLTexture( int nX, int nY, int nWidth, int nHeight )
// nY = GetHeight() - nHeight - nY; // nY = GetHeight() - nHeight - nY;
glGenTextures( 1, &mnTexture ); glGenTextures( 1, &mnTexture );
CHECK_GL_ERROR();
glBindTexture( GL_TEXTURE_2D, mnTexture ); glBindTexture( GL_TEXTURE_2D, mnTexture );
CHECK_GL_ERROR();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
CHECK_GL_ERROR();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
CHECK_GL_ERROR();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
CHECK_GL_ERROR();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
CHECK_GL_ERROR();
glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, nX, nY, nWidth, nHeight, 0 ); glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, nX, nY, nWidth, nHeight, 0 );
CHECK_GL_ERROR(); CHECK_GL_ERROR();
glBindTexture( GL_TEXTURE_2D, 0 ); glBindTexture( GL_TEXTURE_2D, 0 );
CHECK_GL_ERROR();
VCL_GL_INFO( "vcl.opengl", "OpenGLTexture " << mnTexture << " " << nWidth << "x" << nHeight << " from x" << nX << ", y" << nY ); VCL_GL_INFO( "vcl.opengl", "OpenGLTexture " << mnTexture << " " << nWidth << "x" << nHeight << " from x" << nX << ", y" << nY );
CHECK_GL_ERROR();
} }
// texture from buffer data // texture from buffer data
...@@ -89,19 +102,28 @@ ImplOpenGLTexture::ImplOpenGLTexture( int nWidth, int nHeight, int nFormat, int ...@@ -89,19 +102,28 @@ ImplOpenGLTexture::ImplOpenGLTexture( int nWidth, int nHeight, int nFormat, int
mnFreeSlots(-1) mnFreeSlots(-1)
{ {
if( !mnTexture ) if( !mnTexture )
{
glGenTextures( 1, &mnTexture ); glGenTextures( 1, &mnTexture );
CHECK_GL_ERROR();
}
glBindTexture( GL_TEXTURE_2D, mnTexture ); glBindTexture( GL_TEXTURE_2D, mnTexture );
CHECK_GL_ERROR();
glPixelStorei( GL_UNPACK_ALIGNMENT, 1 ); glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
CHECK_GL_ERROR();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
CHECK_GL_ERROR();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
CHECK_GL_ERROR();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
CHECK_GL_ERROR();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
CHECK_GL_ERROR();
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, mnWidth, mnHeight, 0, nFormat, nType, pData ); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, mnWidth, mnHeight, 0, nFormat, nType, pData );
CHECK_GL_ERROR();
glBindTexture( GL_TEXTURE_2D, 0 ); glBindTexture( GL_TEXTURE_2D, 0 );
CHECK_GL_ERROR();
VCL_GL_INFO( "vcl.opengl", "OpenGLTexture " << mnTexture << " " << nWidth << "x" << nHeight << " from data" ); VCL_GL_INFO( "vcl.opengl", "OpenGLTexture " << mnTexture << " " << nWidth << "x" << nHeight << " from data" );
CHECK_GL_ERROR();
} }
ImplOpenGLTexture::~ImplOpenGLTexture() ImplOpenGLTexture::~ImplOpenGLTexture()
...@@ -126,13 +148,16 @@ bool ImplOpenGLTexture::InsertBuffer(int nX, int nY, int nWidth, int nHeight, in ...@@ -126,13 +148,16 @@ bool ImplOpenGLTexture::InsertBuffer(int nX, int nY, int nWidth, int nHeight, in
if (!pData || mnTexture == 0) if (!pData || mnTexture == 0)
return false; return false;
glBindTexture(GL_TEXTURE_2D, mnTexture); glBindTexture(GL_TEXTURE_2D, mnTexture);
CHECK_GL_ERROR();
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
CHECK_GL_ERROR();
glTexSubImage2D(GL_TEXTURE_2D, 0, nX, mnHeight - nY - nHeight, nWidth, nHeight, nFormat, nType, pData); glTexSubImage2D(GL_TEXTURE_2D, 0, nX, mnHeight - nY - nHeight, nWidth, nHeight, nFormat, nType, pData);
CHECK_GL_ERROR();
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
CHECK_GL_ERROR();
VCL_GL_INFO( "vcl.opengl", "OpenGLTexture " << mnTexture << " Insert buff. to " << nX << " " << nY VCL_GL_INFO( "vcl.opengl", "OpenGLTexture " << mnTexture << " Insert buff. to " << nX << " " << nY
<< " size " << nWidth << "x" << nHeight << " from data" ); << " size " << nWidth << "x" << nHeight << " from data" );
CHECK_GL_ERROR();
return true; return true;
} }
...@@ -311,26 +336,28 @@ void OpenGLTexture::SetFilter( GLenum nFilter ) ...@@ -311,26 +336,28 @@ void OpenGLTexture::SetFilter( GLenum nFilter )
{ {
mpImpl->mnFilter = nFilter; mpImpl->mnFilter = nFilter;
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, nFilter ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, nFilter );
CHECK_GL_ERROR();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, nFilter ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, nFilter );
CHECK_GL_ERROR();
} }
CHECK_GL_ERROR();
} }
void OpenGLTexture::Bind() void OpenGLTexture::Bind()
{ {
if( mpImpl ) if( mpImpl )
{
glBindTexture( GL_TEXTURE_2D, mpImpl->mnTexture ); glBindTexture( GL_TEXTURE_2D, mpImpl->mnTexture );
CHECK_GL_ERROR();
CHECK_GL_ERROR(); }
} }
void OpenGLTexture::Unbind() void OpenGLTexture::Unbind()
{ {
if( mpImpl ) if( mpImpl )
{
glBindTexture( GL_TEXTURE_2D, 0 ); glBindTexture( GL_TEXTURE_2D, 0 );
CHECK_GL_ERROR();
CHECK_GL_ERROR(); }
} }
void OpenGLTexture::SaveToFile(const OUString& rFileName) void OpenGLTexture::SaveToFile(const OUString& rFileName)
...@@ -349,8 +376,6 @@ void OpenGLTexture::SaveToFile(const OUString& rFileName) ...@@ -349,8 +376,6 @@ void OpenGLTexture::SaveToFile(const OUString& rFileName)
{ {
SAL_WARN("vcl.opengl", "Error writing png to " << rFileName); SAL_WARN("vcl.opengl", "Error writing png to " << rFileName);
} }
CHECK_GL_ERROR();
} }
void OpenGLTexture::Read( GLenum nFormat, GLenum nType, sal_uInt8* pData ) void OpenGLTexture::Read( GLenum nFormat, GLenum nType, sal_uInt8* pData )
...@@ -367,8 +392,10 @@ void OpenGLTexture::Read( GLenum nFormat, GLenum nType, sal_uInt8* pData ) ...@@ -367,8 +392,10 @@ void OpenGLTexture::Read( GLenum nFormat, GLenum nType, sal_uInt8* pData )
{ {
Bind(); Bind();
glPixelStorei( GL_PACK_ALIGNMENT, 1 ); glPixelStorei( GL_PACK_ALIGNMENT, 1 );
CHECK_GL_ERROR();
// XXX: Call not available with GLES 2.0 // XXX: Call not available with GLES 2.0
glGetTexImage( GL_TEXTURE_2D, 0, nFormat, nType, pData ); glGetTexImage( GL_TEXTURE_2D, 0, nFormat, nType, pData );
CHECK_GL_ERROR();
Unbind(); Unbind();
} }
else else
...@@ -383,11 +410,11 @@ void OpenGLTexture::Read( GLenum nFormat, GLenum nType, sal_uInt8* pData ) ...@@ -383,11 +410,11 @@ void OpenGLTexture::Read( GLenum nFormat, GLenum nType, sal_uInt8* pData )
rtl::Reference<OpenGLContext> pContext = pSVData->maGDIData.mpLastContext; rtl::Reference<OpenGLContext> pContext = pSVData->maGDIData.mpLastContext;
OpenGLFramebuffer* pFramebuffer = pContext->AcquireFramebuffer(*this); OpenGLFramebuffer* pFramebuffer = pContext->AcquireFramebuffer(*this);
glPixelStorei(GL_PACK_ALIGNMENT, 1); glPixelStorei(GL_PACK_ALIGNMENT, 1);
CHECK_GL_ERROR();
glReadPixels(nX, nY, nWidth, nHeight, nFormat, nType, pData); glReadPixels(nX, nY, nWidth, nHeight, nFormat, nType, pData);
CHECK_GL_ERROR();
OpenGLContext::ReleaseFramebuffer(pFramebuffer); OpenGLContext::ReleaseFramebuffer(pFramebuffer);
} }
CHECK_GL_ERROR();
} }
OpenGLTexture::operator bool() const OpenGLTexture::operator bool() const
......
...@@ -96,8 +96,10 @@ bool X11OpenGLSalGraphicsImpl::FillPixmapFromScreen( X11Pixmap* pPixmap, int nX, ...@@ -96,8 +96,10 @@ bool X11OpenGLSalGraphicsImpl::FillPixmapFromScreen( X11Pixmap* pPixmap, int nX,
// TODO: lfrb: What if offscreen? // TODO: lfrb: What if offscreen?
pData = static_cast<char*>(malloc( pPixmap->GetWidth() * pPixmap->GetHeight() * 4 )); pData = static_cast<char*>(malloc( pPixmap->GetWidth() * pPixmap->GetHeight() * 4 ));
glPixelStorei( GL_PACK_ALIGNMENT, 1 ); glPixelStorei( GL_PACK_ALIGNMENT, 1 );
CHECK_GL_ERROR();
glReadPixels( nX, GetHeight() - nY, pPixmap->GetWidth(), pPixmap->GetHeight(), glReadPixels( nX, GetHeight() - nY, pPixmap->GetWidth(), pPixmap->GetHeight(),
GL_RGBA, GL_UNSIGNED_BYTE, pData ); GL_RGBA, GL_UNSIGNED_BYTE, pData );
CHECK_GL_ERROR();
pImage = XCreateImage( pDisplay, aVisualInfo.visual, 24, ZPixmap, 0, pData, pImage = XCreateImage( pDisplay, aVisualInfo.visual, 24, ZPixmap, 0, pData,
pPixmap->GetWidth(), pPixmap->GetHeight(), 8, 0 ); pPixmap->GetWidth(), pPixmap->GetHeight(), 8, 0 );
...@@ -108,7 +110,6 @@ bool X11OpenGLSalGraphicsImpl::FillPixmapFromScreen( X11Pixmap* pPixmap, int nX, ...@@ -108,7 +110,6 @@ bool X11OpenGLSalGraphicsImpl::FillPixmapFromScreen( X11Pixmap* pPixmap, int nX,
XFreeGC( pDisplay, aGC ); XFreeGC( pDisplay, aGC );
XDestroyImage( pImage ); XDestroyImage( pImage );
CHECK_GL_ERROR();
return true; return true;
} }
...@@ -154,6 +155,7 @@ bool X11OpenGLSalGraphicsImpl::RenderPixmap(X11Pixmap* pPixmap, X11Pixmap* pMask ...@@ -154,6 +155,7 @@ bool X11OpenGLSalGraphicsImpl::RenderPixmap(X11Pixmap* pPixmap, X11Pixmap* pMask
rCombo.mpTexture.reset(new OpenGLTexture(pPixmap->GetWidth(), pPixmap->GetHeight(), false)); rCombo.mpTexture.reset(new OpenGLTexture(pPixmap->GetWidth(), pPixmap->GetHeight(), false));
glActiveTexture( GL_TEXTURE0 ); glActiveTexture( GL_TEXTURE0 );
CHECK_GL_ERROR();
rCombo.mpTexture->Bind(); rCombo.mpTexture->Bind();
glXBindTexImageEXT( pDisplay, pGlxPixmap, GLX_FRONT_LEFT_EXT, nullptr ); glXBindTexImageEXT( pDisplay, pGlxPixmap, GLX_FRONT_LEFT_EXT, nullptr );
rCombo.mpTexture->Unbind(); rCombo.mpTexture->Unbind();
......
...@@ -197,7 +197,6 @@ int InitTempWindow(HWND *hwnd, int width, int height, const PIXELFORMATDESCRIPTO ...@@ -197,7 +197,6 @@ int InitTempWindow(HWND *hwnd, int width, int height, const PIXELFORMATDESCRIPTO
return -1; return -1;
} }
CHECK_GL_ERROR();
return 0; return 0;
} }
...@@ -1612,6 +1611,7 @@ OpenGLFramebuffer* OpenGLContext::AcquireFramebuffer( const OpenGLTexture& rText ...@@ -1612,6 +1611,7 @@ OpenGLFramebuffer* OpenGLContext::AcquireFramebuffer( const OpenGLTexture& rText
BindFramebuffer( pFramebuffer ); BindFramebuffer( pFramebuffer );
pFramebuffer->AttachTexture( rTexture ); pFramebuffer->AttachTexture( rTexture );
glViewport( 0, 0, rTexture.GetWidth(), rTexture.GetHeight() ); glViewport( 0, 0, rTexture.GetWidth(), rTexture.GetHeight() );
CHECK_GL_ERROR();
return pFramebuffer; return pFramebuffer;
} }
......
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