summaryrefslogtreecommitdiffstats
path: root/src/graphics/opengl
diff options
context:
space:
mode:
authorMohamed Waheed <mohamedwaheedmohamed@gmail.com>2014-06-24 01:35:05 +0300
committerMohamed Waheed <mohamedwaheedmohamed@gmail.com>2014-06-24 01:35:05 +0300
commit613e1d74c47cf3a756af9aff75575c7567699381 (patch)
treec0cd765cf6983c9be95b81e2aeefeadece9d2b27 /src/graphics/opengl
parent99cd015dd89f0928246d1178c5641ebe325fe997 (diff)
downloadcolobot-613e1d74c47cf3a756af9aff75575c7567699381.tar.gz
colobot-613e1d74c47cf3a756af9aff75575c7567699381.tar.bz2
colobot-613e1d74c47cf3a756af9aff75575c7567699381.zip
implemented savefile screenshot feature
Diffstat (limited to 'src/graphics/opengl')
-rw-r--r--src/graphics/opengl/gldevice.cpp17
-rw-r--r--src/graphics/opengl/gldevice.h2
2 files changed, 19 insertions, 0 deletions
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<unsigned int*> ( static_cast<void*>(pixels) );
+
+ for (int i = 0; i < surface->h * surface->w; ++i)
+ p[i] |= 0xFF000000;
+
+ return static_cast<void*>(p);
+}
} // namespace Gfx
diff --git a/src/graphics/opengl/gldevice.h b/src/graphics/opengl/gldevice.h
index c648161..267ee73 100644
--- a/src/graphics/opengl/gldevice.h
+++ b/src/graphics/opengl/gldevice.h
@@ -188,6 +188,8 @@ public:
virtual void SetFillMode(FillMode mode) ;
virtual FillMode GetFillMode();
+ virtual void* GetFrameBufferPixels()const;
+
private:
//! Updates internal modelview matrix
void UpdateModelviewMatrix();