summaryrefslogtreecommitdiff
path: root/vcl/opengl
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <lfrb@collabora.com>2014-12-04 22:27:38 -0500
committerMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-12-11 07:57:34 +0100
commitb9c25fcc0d6aff0910348dcf3a53c16179f9ab56 (patch)
tree21d2b61be0dfb7d89d5d33c684f861e2c79808a4 /vcl/opengl
parent01bed8089af907e7c0fb8e053d55bffb1eb81aac (diff)
vcl: Don't keep a reference to the texture in the FBO object
Change-Id: I240d2b44e77d28af3cd5952b6d666a1709c4c54a
Diffstat (limited to 'vcl/opengl')
-rw-r--r--vcl/opengl/framebuffer.cxx22
1 files changed, 15 insertions, 7 deletions
diff --git a/vcl/opengl/framebuffer.cxx b/vcl/opengl/framebuffer.cxx
index e760b53f614d..c4dfb05ae4b1 100644
--- a/vcl/opengl/framebuffer.cxx
+++ b/vcl/opengl/framebuffer.cxx
@@ -17,6 +17,7 @@ OpenGLFramebuffer::OpenGLFramebuffer() :
mnId( 0 ),
mnWidth( 0 ),
mnHeight( 0 ),
+ mnAttachedTexture( 0 ),
mpPrevFramebuffer( NULL ),
mpNextFramebuffer( NULL )
{
@@ -45,30 +46,37 @@ void OpenGLFramebuffer::Unbind()
bool OpenGLFramebuffer::IsFree() const
{
- return (!maAttachedTexture);
+ return (!mnAttachedTexture);
}
bool OpenGLFramebuffer::IsAttached( const OpenGLTexture& rTexture ) const
{
- return ( maAttachedTexture == rTexture );
+ return ( mnAttachedTexture == rTexture.Id() );
}
void OpenGLFramebuffer::AttachTexture( const OpenGLTexture& rTexture )
{
+ if( rTexture.Id() == mnAttachedTexture )
+ return;
+
SAL_INFO( "vcl.opengl", "Attaching texture " << rTexture.Id() << " to framebuffer " << (int)mnId );
- maAttachedTexture = rTexture;
+ mnAttachedTexture = rTexture.Id();
mnWidth = rTexture.GetWidth();
mnHeight = rTexture.GetHeight();
glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
- maAttachedTexture.Id(), 0 );
+ mnAttachedTexture, 0 );
CHECK_GL_ERROR();
}
void OpenGLFramebuffer::DetachTexture()
{
- maAttachedTexture = OpenGLTexture();
- glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0 );
- CHECK_GL_ERROR();
+ if( mnAttachedTexture != 0 )
+ {
+ CHECK_GL_ERROR();
+ mnAttachedTexture = 0;
+ glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0 );
+ CHECK_GL_ERROR();
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */