diff options
author | Louis-Francis Ratté-Boulianne <lfrb@collabora.com> | 2014-12-02 16:42:32 -0500 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2014-12-03 14:05:36 +0100 |
commit | fa83f036a18341c79da0ae6cf3b60a7ce53544c1 (patch) | |
tree | 7cc48b908eda68b8b64ee431c6ed9edf618cfdc2 /vcl | |
parent | edbdaf07d9b7a9304294c8ed650ed85f81b52e14 (diff) |
vcl: Acquire framebuffer from current context when reading back texture
Change-Id: I410ac2d10ec2e498d9d8444e5584bfb14727c90b
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/opengl/texture.cxx | 22 |
1 files changed, 10 insertions, 12 deletions
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 <sal/config.h> +#include <vcl/opengl/OpenGLContext.hxx> #include <vcl/opengl/OpenGLHelper.hxx> +#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(); |