Browse Source

gpu: implement Framebuffer::GetImage() for OpenGL.

undefined
Sam Hocevar 10 years ago
parent
commit
ff8723ff63
2 changed files with 18 additions and 0 deletions
  1. +16
    -0
      src/gpu/framebuffer.cpp
  2. +2
    -0
      src/lol/gpu/framebuffer.h

+ 16
- 0
src/gpu/framebuffer.cpp View File

@@ -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<PixelFormat::RGBA_8>();
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");


+ 2
- 0
src/lol/gpu/framebuffer.h View File

@@ -104,6 +104,8 @@ public:
TextureUniform GetTextureUniform() const;
ivec2 GetSize() const;

class Image GetImage() const;

void Bind();
void Unbind();



Loading…
Cancel
Save