From fa83f036a18341c79da0ae6cf3b60a7ce53544c1 Mon Sep 17 00:00:00 2001 From: Louis-Francis Ratté-Boulianne Date: Tue, 2 Dec 2014 16:42:32 -0500 Subject: vcl: Acquire framebuffer from current context when reading back texture Change-Id: I410ac2d10ec2e498d9d8444e5584bfb14727c90b --- vcl/opengl/texture.cxx | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'vcl/opengl') diff --git a/vcl/opengl/texture.cxx b/vcl/opengl/texture.cxx index cc5be7800fa1..e4bc5326a47b 100644 --- a/vcl/opengl/texture.cxx +++ b/vcl/opengl/texture.cxx @@ -18,10 +18,14 @@ */ #include +#include #include +#include "svdata.hxx" + #include "vcl/salbtype.hxx" +#include "opengl/framebuffer.hxx" #include "opengl/texture.hxx" // texture with allocated size @@ -299,21 +303,15 @@ void OpenGLTexture::Read( GLenum nFormat, GLenum nType, sal_uInt8* pData ) } else { - GLuint nFramebufferId; - glGenFramebuffers( 1, &nFramebufferId ); - glBindFramebuffer( GL_FRAMEBUFFER, nFramebufferId ); - CHECK_GL_ERROR(); + // Retrieve current context + ImplSVData* pSVData = ImplGetSVData(); + OpenGLContext* pContext = pSVData->maGDIData.mpLastContext; + OpenGLFramebuffer* pFramebuffer; - glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, Id(), 0 ); - CHECK_GL_ERROR(); + pFramebuffer = pContext->AcquireFramebuffer( *this ); glReadPixels( maRect.Left(), mpImpl->mnHeight - maRect.Top(), GetWidth(), GetHeight(), nFormat, nType, pData ); + pContext->ReleaseFramebuffer( pFramebuffer ); CHECK_GL_ERROR(); - - glBindFramebuffer( GL_FRAMEBUFFER, 0 ); - glDeleteFramebuffers( 1, &nFramebufferId ); - - int bpp = (nFormat == GL_RGB) ? 3 : 4; - memset( pData, 255, GetWidth() * GetHeight() * bpp ); } Unbind(); -- cgit