diff --git a/source/g3d_viewer/renderer.cpp b/source/g3d_viewer/renderer.cpp index d8b7754e..fb9673dc 100644 --- a/source/g3d_viewer/renderer.cpp +++ b/source/g3d_viewer/renderer.cpp @@ -15,7 +15,7 @@ #include "graphics_interface.h" #include "config.h" #include "platform_common.h" -#include +//#include using namespace Shared::Graphics; using namespace Shared::Graphics::Gl; diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index a08857d0..40276ca8 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -37,7 +37,7 @@ #include "ImageReaders.h" #include "renderer.h" #include "simple_threads.h" -#include +//#include #include "font.h" #include #include "menu_state_masterserver.h" diff --git a/source/glest_map_editor/main.cpp b/source/glest_map_editor/main.cpp index ae05ba40..bad60d3a 100644 --- a/source/glest_map_editor/main.cpp +++ b/source/glest_map_editor/main.cpp @@ -22,7 +22,7 @@ #include #endif #include "common_scoped_ptr.h" -#include +//#include using namespace Shared::Util; using namespace Shared::PlatformCommon; diff --git a/source/shared_lib/include/graphics/model.h b/source/shared_lib/include/graphics/model.h index 962e0461..eee2ff3a 100644 --- a/source/shared_lib/include/graphics/model.h +++ b/source/shared_lib/include/graphics/model.h @@ -316,6 +316,7 @@ private: static vector > nextColorIDReuseList; static auto_ptr pbo; + //static auto_ptr cachedPixels; void assign_color(); diff --git a/source/shared_lib/sources/graphics/model.cpp b/source/shared_lib/sources/graphics/model.cpp index d6dc0e4e..18ea62bc 100644 --- a/source/shared_lib/sources/graphics/model.cpp +++ b/source/shared_lib/sources/graphics/model.cpp @@ -21,7 +21,7 @@ #include "platform_common.h" #include "opengl.h" #include "platform_util.h" -#include +//#include #include #include #include "leak_dumper.h" @@ -1806,7 +1806,7 @@ Pixmap2D *PixelBufferWrapper::getPixelBufferFor(int x,int y,int w,int h, int col Pixmap2D *pixmapScreenShot = NULL; if(PixelBufferWrapper::isPBOEnabled == true) { string codeSection = "A"; - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] ",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); try { // increment current index first then get the next index // "index" is used to read pixels from a framebuffer to a PBO @@ -1814,23 +1814,24 @@ Pixmap2D *PixelBufferWrapper::getPixelBufferFor(int x,int y,int w,int h, int col index = (index + 1) % 2; codeSection = "B"; - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] ",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); // Check for out of range if(index >= (int)pboIds.size()) { char szBuf[8096]=""; snprintf(szBuf,8096,"Error / Warning in [%s::%s] on line: %d pixel buffer out of range, index: %d size: %d, attempting to expand buffer...\n",__FILE__,__FUNCTION__,__LINE__,index, (int)pboIds.size()); //throw megaglest_runtime_error(szBuf); SystemFlags::OutputDebug(SystemFlags::debugError,"%s",szBuf); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] szBuf: %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,szBuf); codeSection = "C"; - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] ",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); addBuffersToPixelBuf((index - pboIds.size()) + 1); } // pbo index used for next frame //int nextIndex = (index + 1) % 2; codeSection = "D"; - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] ",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); // read framebuffer /////////////////////////////// // copy pixels from framebuffer to PBO // Use offset instead of pointer. @@ -1839,7 +1840,7 @@ Pixmap2D *PixelBufferWrapper::getPixelBufferFor(int x,int y,int w,int h, int col //glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[nextIndex]); codeSection = "E"; - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] ",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //glPixelStorei(GL_PACK_ALIGNMENT, 1); glReadPixels(x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, 0); //glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -1852,34 +1853,36 @@ Pixmap2D *PixelBufferWrapper::getPixelBufferFor(int x,int y,int w,int h, int col //t1.start(); codeSection = "F"; - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] ",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); // map the PBO that contain framebuffer pixels before processing it //glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[nextIndex]); glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[index]); codeSection = "G"; - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] ",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); GLubyte* src = (GLubyte*)glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY_ARB); if(src) { codeSection = "H"; - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] ",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); pixmapScreenShot = new Pixmap2D(w, h, colorComponents); codeSection = "I"; - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] ",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); memcpy(pixmapScreenShot->getPixels(),src,pixmapScreenShot->getPixelByteCount()); codeSection = "J"; - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] ",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB); // release pointer to the mapped buffer //pixmapScreenShot->save("debugPBO.png"); } codeSection = "K"; - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] ",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); // measure the time reading framebuffer //t1.stop(); //processTime = t1.getElapsedTimeInMilliSec(); glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); + + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); } catch(megaglest_runtime_error& ex) { SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] codeSection [%s] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,codeSection.c_str(),ex.what()); @@ -1893,6 +1896,7 @@ Pixmap2D *PixelBufferWrapper::getPixelBufferFor(int x,int y,int w,int h, int col SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] codeSection [%s] UNKNOWN Error!",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,codeSection.c_str()); throw megaglest_runtime_error("UNKNOWN Exception caught in getPixelBufferFor codeSection: " + codeSection +"\n"); } + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); } return pixmapScreenShot; @@ -1938,6 +1942,7 @@ unsigned int BaseColorPickEntity::nextColorRGB = BaseColorPickEntity::k; unsigned char BaseColorPickEntity::nextColorID[COLOR_COMPONENTS] = { 1, 1, 1, 0 }; auto_ptr BaseColorPickEntity::pbo; +//auto_ptr BaseColorPickEntity::cachedPixels; map BaseColorPickEntity::usedColorIDList; bool BaseColorPickEntity::trackColorUse = true; @@ -2107,6 +2112,13 @@ void BaseColorPickEntity::resetUniqueColors() { } void BaseColorPickEntity::init(int bufferSize) { if(BaseColorPickEntity::pbo.get() == NULL) { + //printf("BaseColorPickEntity::init pbo == null\n"); + BaseColorPickEntity::bufferSizeRequired = bufferSize; + BaseColorPickEntity::pbo.reset(new PixelBufferWrapper(2,BaseColorPickEntity::bufferSizeRequired)); + } + else if(bufferSize != BaseColorPickEntity::bufferSizeRequired) { + //printf("BaseColorPickEntity::init pbo resize\n"); + cleanupPBO(); BaseColorPickEntity::bufferSizeRequired = bufferSize; BaseColorPickEntity::pbo.reset(new PixelBufferWrapper(2,BaseColorPickEntity::bufferSizeRequired)); } @@ -2170,7 +2182,9 @@ vector BaseColorPickEntity::getPickedList(int x,int y,int w,int h, //printf("In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); static auto_ptr cachedPixels; + //auto_ptr cachedPixels; + //printf("PixelBufferWrapper::getIsPBOEnable() = %d\n",PixelBufferWrapper::getIsPBOEnable()); if(rendererModels.empty() == false) { if(PixelBufferWrapper::getIsPBOEnable() == true) { Pixmap2D *pixmapScreenShot = BaseColorPickEntity::pbo->getPixelBufferFor(x,y,w,h, COLOR_COMPONENTS); diff --git a/source/shared_lib/sources/graphics/pixmap.cpp b/source/shared_lib/sources/graphics/pixmap.cpp index cfd24b27..bf64573a 100644 --- a/source/shared_lib/sources/graphics/pixmap.cpp +++ b/source/shared_lib/sources/graphics/pixmap.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +//#include #include "opengl.h" #include "leak_dumper.h"