mirror of
https://github.com/glest/glest-source.git
synced 2025-08-09 18:06:30 +02:00
- changed code to cleanup pixbuf allocation earlier to not confuse gDEbugger about an openGL memory leak.
This commit is contained in:
@@ -446,6 +446,7 @@ Game::~Game() {
|
|||||||
// unit particles and fade them out etc and this end method deletes the original
|
// unit particles and fade them out etc and this end method deletes the original
|
||||||
// object pointers.
|
// object pointers.
|
||||||
renderer.endGame(true);
|
renderer.endGame(true);
|
||||||
|
BaseColorPickEntity::cleanupPBO();
|
||||||
|
|
||||||
GameConstants::updateFps = original_updateFps;
|
GameConstants::updateFps = original_updateFps;
|
||||||
GameConstants::cameraFps = original_cameraFps;
|
GameConstants::cameraFps = original_cameraFps;
|
||||||
|
@@ -292,8 +292,11 @@ public:
|
|||||||
|
|
||||||
static int getUsedColorIDListSize() { return (int)usedColorIDList.size(); }
|
static int getUsedColorIDListSize() { return (int)usedColorIDList.size(); }
|
||||||
|
|
||||||
|
static void cleanupPBO();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
static int bufferSizeRequired;
|
||||||
unsigned char uniqueColorID[COLOR_COMPONENTS];
|
unsigned char uniqueColorID[COLOR_COMPONENTS];
|
||||||
|
|
||||||
static unsigned char nextColorID[COLOR_COMPONENTS];
|
static unsigned char nextColorID[COLOR_COMPONENTS];
|
||||||
|
@@ -1761,6 +1761,8 @@ PixelBufferWrapper::PixelBufferWrapper(int pboCount,int bufferSize) {
|
|||||||
//
|
//
|
||||||
|
|
||||||
for(int i = 0; i < pboCount; ++i) {
|
for(int i = 0; i < pboCount; ++i) {
|
||||||
|
printf("PBO Gen i = %d\n",i);
|
||||||
|
|
||||||
pboIds.push_back(0);
|
pboIds.push_back(0);
|
||||||
glGenBuffersARB(1, (GLuint*)&pboIds[i]);
|
glGenBuffersARB(1, (GLuint*)&pboIds[i]);
|
||||||
// create pixel buffer objects, you need to delete them when program exits.
|
// create pixel buffer objects, you need to delete them when program exits.
|
||||||
@@ -1838,8 +1840,12 @@ void PixelBufferWrapper::end() {
|
|||||||
void PixelBufferWrapper::cleanup() {
|
void PixelBufferWrapper::cleanup() {
|
||||||
if(PixelBufferWrapper::isPBOEnabled == true) {
|
if(PixelBufferWrapper::isPBOEnabled == true) {
|
||||||
if(pboIds.empty() == false) {
|
if(pboIds.empty() == false) {
|
||||||
|
printf("PBO Delete size = %d\n",(int)pboIds.size());
|
||||||
|
|
||||||
glDeleteBuffersARB((int)pboIds.size(), &pboIds[0]);
|
glDeleteBuffersARB((int)pboIds.size(), &pboIds[0]);
|
||||||
pboIds.clear();
|
pboIds.clear();
|
||||||
|
|
||||||
|
glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1850,6 +1856,7 @@ PixelBufferWrapper::~PixelBufferWrapper() {
|
|||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
int BaseColorPickEntity::bufferSizeRequired = -1;
|
||||||
const unsigned int BaseColorPickEntity::p = 64007;
|
const unsigned int BaseColorPickEntity::p = 64007;
|
||||||
const unsigned int BaseColorPickEntity::k = 43067;
|
const unsigned int BaseColorPickEntity::k = 43067;
|
||||||
unsigned int BaseColorPickEntity::nextColorRGB = BaseColorPickEntity::k;
|
unsigned int BaseColorPickEntity::nextColorRGB = BaseColorPickEntity::k;
|
||||||
@@ -1865,6 +1872,9 @@ vector<vector<unsigned char> > BaseColorPickEntity::nextColorIDReuseList;
|
|||||||
bool BaseColorPickEntity::using_loop_method = false;
|
bool BaseColorPickEntity::using_loop_method = false;
|
||||||
|
|
||||||
BaseColorPickEntity::BaseColorPickEntity() {
|
BaseColorPickEntity::BaseColorPickEntity() {
|
||||||
|
if(BaseColorPickEntity::bufferSizeRequired != -1) {
|
||||||
|
BaseColorPickEntity::init(BaseColorPickEntity::bufferSizeRequired);
|
||||||
|
}
|
||||||
uniqueColorID[0] = 0;
|
uniqueColorID[0] = 0;
|
||||||
uniqueColorID[1] = 0;
|
uniqueColorID[1] = 0;
|
||||||
uniqueColorID[2] = 0;
|
uniqueColorID[2] = 0;
|
||||||
@@ -2022,10 +2032,15 @@ void BaseColorPickEntity::resetUniqueColors() {
|
|||||||
}
|
}
|
||||||
void BaseColorPickEntity::init(int bufferSize) {
|
void BaseColorPickEntity::init(int bufferSize) {
|
||||||
if(BaseColorPickEntity::pbo.get() == NULL) {
|
if(BaseColorPickEntity::pbo.get() == NULL) {
|
||||||
BaseColorPickEntity::pbo.reset(new PixelBufferWrapper(2,bufferSize));
|
BaseColorPickEntity::bufferSizeRequired = bufferSize;
|
||||||
|
BaseColorPickEntity::pbo.reset(new PixelBufferWrapper(2,BaseColorPickEntity::bufferSizeRequired));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseColorPickEntity::cleanupPBO() {
|
||||||
|
BaseColorPickEntity::pbo.reset(0);
|
||||||
|
}
|
||||||
|
|
||||||
string BaseColorPickEntity::getColorDescription() const {
|
string BaseColorPickEntity::getColorDescription() const {
|
||||||
char szBuf[100]="";
|
char szBuf[100]="";
|
||||||
snprintf(szBuf,100,"%d.%d.%d",uniqueColorID[0],uniqueColorID[1],uniqueColorID[2]);
|
snprintf(szBuf,100,"%d.%d.%d",uniqueColorID[0],uniqueColorID[1],uniqueColorID[2]);
|
||||||
|
Reference in New Issue
Block a user