Commit 016b5c75 authored by Janis Born's avatar Janis Born
Browse files

add static method to FrameBufferObject to read out current contents of the default frame buffer

parent 97fb9f79
......@@ -217,6 +217,10 @@ public:
//! get a list of attachment locations and names that can be used to set up a ShaderProgram
SharedLocationMappings getAttachmentLocations() const;
//! returns the current contents of the default FrameBuffer
//! the format of the returned TextureData will be GL_RGB, the type will be GL_UNSIGNED_INT
static SharedTextureData getImageData(GLsizei _width, GLsizei _height, GLint _x = 0, GLint _y = 0, GLenum _readBuffer = GL_INVALID_ENUM);
// =================================================================================================== \/
// ============================================================================================ FIELDS \/
// =================================================================================================== \/
......@@ -204,3 +204,25 @@ SharedLocationMappings FrameBufferObject::getAttachmentLocations() const
return locationMap;
SharedTextureData FrameBufferObject::getImageData(GLsizei _width, GLsizei _height, GLint _x, GLint _y, GLenum _readBuffer)
GLubyte* frameBufferData = new GLubyte[_width * _height * 3];
glBindFramebuffer(GL_FRAMEBUFFER, 0);
if(_readBuffer != GL_INVALID_ENUM)
glReadPixels(_x, _y, _width, _height, GL_RGB, GL_UNSIGNED_BYTE, frameBufferData);
SharedTextureData texData = SharedTextureData(new TextureData());
texData->setData(frameBufferData); // frameBufferData memory will be managed by texData
return texData;
Supports Markdown
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