diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 4297573b..59154fa9 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -155,6 +155,8 @@ Renderer::Renderer() { lastRenderFps=MIN_FPS_NORMAL_RENDERING; shadowsOffDueToMinRender=false; + pixmapScreenShot = NULL;; + //resources for(int i=0; i < rsCount; ++i) { modelManager[i] = NULL; @@ -208,6 +210,8 @@ Renderer::~Renderer(){ fontManager[i] = NULL; } + delete pixmapScreenShot; + this->menu = NULL; this->game = NULL; } @@ -2858,11 +2862,29 @@ void Renderer::saveScreen(const string &path){ const Metrics &sm= Metrics::getInstance(); - Pixmap2D pixmap(sm.getScreenW(), sm.getScreenH(), 3); + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + //Pixmap2D pixmap(sm.getScreenW(), sm.getScreenH(), 3); + if( pixmapScreenShot == NULL || + pixmapScreenShot->getW() != sm.getScreenW() || + pixmapScreenShot->getH() != sm.getScreenH()) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + + delete pixmapScreenShot; + pixmapScreenShot = new Pixmap2D(sm.getScreenW(), sm.getScreenH(), 3); + } + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); glFinish(); - glReadPixels(0, 0, pixmap.getW(), pixmap.getH(), GL_RGB, GL_UNSIGNED_BYTE, pixmap.getPixels()); - pixmap.saveTga(path); + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + glReadPixels(0, 0, pixmapScreenShot->getW(), pixmapScreenShot->getH(), + GL_RGB, GL_UNSIGNED_BYTE, pixmapScreenShot->getPixels()); + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + pixmapScreenShot->saveTga(path); + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); } // ==================== PRIVATE ==================== diff --git a/source/glest_game/graphics/renderer.h b/source/glest_game/graphics/renderer.h index c82b4d28..8289f23a 100644 --- a/source/glest_game/graphics/renderer.h +++ b/source/glest_game/graphics/renderer.h @@ -240,6 +240,9 @@ private: bool shadowsOffDueToMinRender; bool useQuadCache; + + Pixmap2D *pixmapScreenShot; + private: Renderer(); ~Renderer(); diff --git a/source/shared_lib/sources/graphics/pixmap.cpp b/source/shared_lib/sources/graphics/pixmap.cpp index 6df3c457..f76b5d12 100644 --- a/source/shared_lib/sources/graphics/pixmap.cpp +++ b/source/shared_lib/sources/graphics/pixmap.cpp @@ -725,7 +725,7 @@ void Pixmap2D::subCopy(int x, int y, const Pixmap2D *sourcePixmap){ } } - delete pixel; + delete [] pixel; } bool Pixmap2D::doDimensionsAgree(const Pixmap2D *pixmap){