|
|
@ -21,7 +21,7 @@
|
|
|
|
#include "platform_common.h"
|
|
|
|
#include "platform_common.h"
|
|
|
|
#include "opengl.h"
|
|
|
|
#include "opengl.h"
|
|
|
|
#include "platform_util.h"
|
|
|
|
#include "platform_util.h"
|
|
|
|
#include <memory>
|
|
|
|
//#include <memory>
|
|
|
|
#include <map>
|
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
#include <vector>
|
|
|
|
#include "leak_dumper.h"
|
|
|
|
#include "leak_dumper.h"
|
|
|
@ -1806,7 +1806,7 @@ Pixmap2D *PixelBufferWrapper::getPixelBufferFor(int x,int y,int w,int h, int col
|
|
|
|
Pixmap2D *pixmapScreenShot = NULL;
|
|
|
|
Pixmap2D *pixmapScreenShot = NULL;
|
|
|
|
if(PixelBufferWrapper::isPBOEnabled == true) {
|
|
|
|
if(PixelBufferWrapper::isPBOEnabled == true) {
|
|
|
|
string codeSection = "A";
|
|
|
|
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 {
|
|
|
|
try {
|
|
|
|
// increment current index first then get the next index
|
|
|
|
// increment current index first then get the next index
|
|
|
|
// "index" is used to read pixels from a framebuffer to a PBO
|
|
|
|
// "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;
|
|
|
|
index = (index + 1) % 2;
|
|
|
|
|
|
|
|
|
|
|
|
codeSection = "B";
|
|
|
|
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
|
|
|
|
// Check for out of range
|
|
|
|
if(index >= (int)pboIds.size()) {
|
|
|
|
if(index >= (int)pboIds.size()) {
|
|
|
|
char szBuf[8096]="";
|
|
|
|
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());
|
|
|
|
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);
|
|
|
|
//throw megaglest_runtime_error(szBuf);
|
|
|
|
SystemFlags::OutputDebug(SystemFlags::debugError,"%s",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";
|
|
|
|
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);
|
|
|
|
addBuffersToPixelBuf((index - pboIds.size()) + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// pbo index used for next frame
|
|
|
|
// pbo index used for next frame
|
|
|
|
//int nextIndex = (index + 1) % 2;
|
|
|
|
//int nextIndex = (index + 1) % 2;
|
|
|
|
|
|
|
|
|
|
|
|
codeSection = "D";
|
|
|
|
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 ///////////////////////////////
|
|
|
|
// read framebuffer ///////////////////////////////
|
|
|
|
// copy pixels from framebuffer to PBO
|
|
|
|
// copy pixels from framebuffer to PBO
|
|
|
|
// Use offset instead of pointer.
|
|
|
|
// 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]);
|
|
|
|
//glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[nextIndex]);
|
|
|
|
|
|
|
|
|
|
|
|
codeSection = "E";
|
|
|
|
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);
|
|
|
|
//glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
|
|
|
glReadPixels(x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
|
|
|
glReadPixels(x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
|
|
|
//glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
|
|
|
//glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
|
|
@ -1852,34 +1853,36 @@ Pixmap2D *PixelBufferWrapper::getPixelBufferFor(int x,int y,int w,int h, int col
|
|
|
|
//t1.start();
|
|
|
|
//t1.start();
|
|
|
|
|
|
|
|
|
|
|
|
codeSection = "F";
|
|
|
|
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
|
|
|
|
// 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[nextIndex]);
|
|
|
|
glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[index]);
|
|
|
|
glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[index]);
|
|
|
|
|
|
|
|
|
|
|
|
codeSection = "G";
|
|
|
|
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);
|
|
|
|
GLubyte* src = (GLubyte*)glMapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY_ARB);
|
|
|
|
if(src) {
|
|
|
|
if(src) {
|
|
|
|
codeSection = "H";
|
|
|
|
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);
|
|
|
|
pixmapScreenShot = new Pixmap2D(w, h, colorComponents);
|
|
|
|
|
|
|
|
|
|
|
|
codeSection = "I";
|
|
|
|
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());
|
|
|
|
memcpy(pixmapScreenShot->getPixels(),src,pixmapScreenShot->getPixelByteCount());
|
|
|
|
|
|
|
|
|
|
|
|
codeSection = "J";
|
|
|
|
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
|
|
|
|
glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB); // release pointer to the mapped buffer
|
|
|
|
//pixmapScreenShot->save("debugPBO.png");
|
|
|
|
//pixmapScreenShot->save("debugPBO.png");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
codeSection = "K";
|
|
|
|
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
|
|
|
|
// measure the time reading framebuffer
|
|
|
|
//t1.stop();
|
|
|
|
//t1.stop();
|
|
|
|
//processTime = t1.getElapsedTimeInMilliSec();
|
|
|
|
//processTime = t1.getElapsedTimeInMilliSec();
|
|
|
|
glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);
|
|
|
|
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) {
|
|
|
|
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());
|
|
|
|
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());
|
|
|
|
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");
|
|
|
|
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;
|
|
|
|
return pixmapScreenShot;
|
|
|
@ -1938,6 +1942,7 @@ unsigned int BaseColorPickEntity::nextColorRGB = BaseColorPickEntity::k;
|
|
|
|
|
|
|
|
|
|
|
|
unsigned char BaseColorPickEntity::nextColorID[COLOR_COMPONENTS] = { 1, 1, 1, 0 };
|
|
|
|
unsigned char BaseColorPickEntity::nextColorID[COLOR_COMPONENTS] = { 1, 1, 1, 0 };
|
|
|
|
auto_ptr<PixelBufferWrapper> BaseColorPickEntity::pbo;
|
|
|
|
auto_ptr<PixelBufferWrapper> BaseColorPickEntity::pbo;
|
|
|
|
|
|
|
|
//auto_ptr<Pixmap2D> BaseColorPickEntity::cachedPixels;
|
|
|
|
|
|
|
|
|
|
|
|
map<string,bool> BaseColorPickEntity::usedColorIDList;
|
|
|
|
map<string,bool> BaseColorPickEntity::usedColorIDList;
|
|
|
|
bool BaseColorPickEntity::trackColorUse = true;
|
|
|
|
bool BaseColorPickEntity::trackColorUse = true;
|
|
|
@ -2107,6 +2112,13 @@ void BaseColorPickEntity::resetUniqueColors() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void BaseColorPickEntity::init(int bufferSize) {
|
|
|
|
void BaseColorPickEntity::init(int bufferSize) {
|
|
|
|
if(BaseColorPickEntity::pbo.get() == NULL) {
|
|
|
|
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::bufferSizeRequired = bufferSize;
|
|
|
|
BaseColorPickEntity::pbo.reset(new PixelBufferWrapper(2,BaseColorPickEntity::bufferSizeRequired));
|
|
|
|
BaseColorPickEntity::pbo.reset(new PixelBufferWrapper(2,BaseColorPickEntity::bufferSizeRequired));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2170,7 +2182,9 @@ vector<int> BaseColorPickEntity::getPickedList(int x,int y,int w,int h,
|
|
|
|
|
|
|
|
|
|
|
|
//printf("In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
|
|
//printf("In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
|
|
static auto_ptr<Pixmap2D> cachedPixels;
|
|
|
|
static auto_ptr<Pixmap2D> cachedPixels;
|
|
|
|
|
|
|
|
//auto_ptr<Pixmap2D> cachedPixels;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//printf("PixelBufferWrapper::getIsPBOEnable() = %d\n",PixelBufferWrapper::getIsPBOEnable());
|
|
|
|
if(rendererModels.empty() == false) {
|
|
|
|
if(rendererModels.empty() == false) {
|
|
|
|
if(PixelBufferWrapper::getIsPBOEnable() == true) {
|
|
|
|
if(PixelBufferWrapper::getIsPBOEnable() == true) {
|
|
|
|
Pixmap2D *pixmapScreenShot = BaseColorPickEntity::pbo->getPixelBufferFor(x,y,w,h, COLOR_COMPONENTS);
|
|
|
|
Pixmap2D *pixmapScreenShot = BaseColorPickEntity::pbo->getPixelBufferFor(x,y,w,h, COLOR_COMPONENTS);
|
|
|
|