diff --git a/src/gpu/framebuffer.cpp b/src/gpu/framebuffer.cpp index ad20b93a..f96163ad 100644 --- a/src/gpu/framebuffer.cpp +++ b/src/gpu/framebuffer.cpp @@ -450,6 +450,22 @@ ivec2 Framebuffer::GetSize() const return m_data->m_size; } +Image Framebuffer::GetImage() const +{ + Image ret(m_data->m_size); + +#if defined USE_D3D9 || defined _XBOX + /* TODO: implement D3D Framebuffer::GetImage() */ +#else + u8vec4 *buffer = ret.Lock(); + glReadPixels(0, 0, m_data->m_size.x, m_data->m_size.y, + GL_BGRA, GL_UNSIGNED_BYTE, buffer); + ret.Unlock(buffer); +#endif + + return ret; +} + void Framebuffer::Bind() { ASSERT(!m_data->m_bound, "trying to bind an already bound framebuffer"); diff --git a/src/lol/gpu/framebuffer.h b/src/lol/gpu/framebuffer.h index a9935122..93796993 100644 --- a/src/lol/gpu/framebuffer.h +++ b/src/lol/gpu/framebuffer.h @@ -104,6 +104,8 @@ public: TextureUniform GetTextureUniform() const; ivec2 GetSize() const; + class Image GetImage() const; + void Bind(); void Unbind();