From 613e1d74c47cf3a756af9aff75575c7567699381 Mon Sep 17 00:00:00 2001 From: Mohamed Waheed Date: Tue, 24 Jun 2014 01:35:05 +0300 Subject: implemented savefile screenshot feature --- src/graphics/opengl/gldevice.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/graphics/opengl/gldevice.cpp') diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp index 9f64fab..57738a6 100644 --- a/src/graphics/opengl/gldevice.cpp +++ b/src/graphics/opengl/gldevice.cpp @@ -1791,6 +1791,23 @@ FillMode CGLDevice::GetFillMode() return FILL_POINT; } +void* CGLDevice::GetFrameBufferPixels()const{ + + SDL_Surface* surface = SDL_GetVideoSurface(); + + assert(surface != nullptr); + + GLubyte* pixels = new GLubyte [4 * surface->h * surface->w]; + + glReadPixels(0,0,surface->w,surface->h,GL_RGBA,GL_UNSIGNED_BYTE,pixels); + + unsigned int* p = static_cast ( static_cast(pixels) ); + + for (int i = 0; i < surface->h * surface->w; ++i) + p[i] |= 0xFF000000; + + return static_cast(p); +} } // namespace Gfx -- cgit v1.2.3-1-g7c22 From b7125a5b24bc6d2581bec0d3f792ba948e0e7edd Mon Sep 17 00:00:00 2001 From: Mohamed Waheed Date: Tue, 24 Jun 2014 20:27:31 +0300 Subject: formatting and enhancements for savefile screenshot feature --- src/graphics/opengl/gldevice.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/graphics/opengl/gldevice.cpp') diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp index 57738a6..b42f29d 100644 --- a/src/graphics/opengl/gldevice.cpp +++ b/src/graphics/opengl/gldevice.cpp @@ -1793,17 +1793,13 @@ FillMode CGLDevice::GetFillMode() void* CGLDevice::GetFrameBufferPixels()const{ - SDL_Surface* surface = SDL_GetVideoSurface(); - - assert(surface != nullptr); - - GLubyte* pixels = new GLubyte [4 * surface->h * surface->w]; + GLubyte* pixels = new GLubyte [4 * m_config.size.x * m_config.size.y]; - glReadPixels(0,0,surface->w,surface->h,GL_RGBA,GL_UNSIGNED_BYTE,pixels); + glReadPixels(0, 0, m_config.size.x, m_config.size.y, GL_RGBA, GL_UNSIGNED_BYTE, pixels); unsigned int* p = static_cast ( static_cast(pixels) ); - for (int i = 0; i < surface->h * surface->w; ++i) + for (int i = 0; i < m_config.size.x * m_config.size.y; ++i) p[i] |= 0xFF000000; return static_cast(p); -- cgit v1.2.3-1-g7c22