Jump to content
  • Advertisement
Sign in to follow this  
kikosmalltalk

OpenGL Book: Beginning OpenGL memory leak !

This topic is 2810 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all

I'm reading the book "Beginning OpenGL game programming".
This book have any examples that have memory leak.
Here the code of the example7 and 8.

http://www.mediafire.com/?4wyhibjwnfcrwrv

I'm using GLIntercept with the example 7 "Terrain".
Here the gllog:

GL Intercept Log. Version : 1.0 Compile Date: Feb 10 2010 Run on: Thu Nov 11 17:41:19 2010

===================================================
Token ->ProfileName not accessed in the configuration file
Token ->ProfileDescription not accessed in the configuration file
InterceptDisplayList::CreateListPre - Attempt to end a list while not compiling a list
glEndList called whithout a glNewList
GL ERROR - Function glEndList generated error GL_INVALID_OPERATION
InterceptDisplayList::CreateListPre - Attempt to end a list while not compiling a list
glEndList called whithout a glNewList
GL ERROR - Function glEndList generated error GL_INVALID_OPERATION
ImageManager::Destructor - OpenGL id 1 is still active. (Image Memory leak?)
ImageManager::Destructor - OpenGL id 2 is still active. (Image Memory leak?)
ImageManager::Destructor - OpenGL id 3 is still active. (Image Memory leak?)
ImageManager::Destructor - OpenGL id 4 is still active. (Image Memory leak?)
ImageManager::Destructor - OpenGL id 5 is still active. (Image Memory leak?)
ImageManager::Destructor - OpenGL id 6 is still active. (Image Memory leak?)
ImageManager::Destructor - OpenGL id 7 is still active. (Image Memory leak?)
ImageManager::Destructor - OpenGL id 8 is still active. (Image Memory leak?)
===================================================
Log End.


Here the glInterceptLog.

http://www.mediafire.com/?uwewyx9rsl1v7df

The error is in this method:

void CGfxOpenGL::DrawTerrain()
{
// draw the terrain
glBindTexture(GL_TEXTURE_2D, m_grassTexture);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
for (int z = 0; z < TERRAIN_SIZE - 1; ++z)
{
glBegin(GL_TRIANGLE_STRIP);
for (int x = 0; x < TERRAIN_SIZE; ++x)
{
// render two vertices of the strip at once
float scaledHeight = heightmap[z * TERRAIN_SIZE + x] / SCALE_FACTOR;
float nextScaledHeight = heightmap[(z + 1)* TERRAIN_SIZE + x] / SCALE_FACTOR;
float color = 0.5f + 0.5f * scaledHeight / MAX_HEIGHT;
float nextColor = 0.5f + 0.5f * nextScaledHeight / MAX_HEIGHT;

glColor3f(color, color, color);
glTexCoord2f((GLfloat)x/TERRAIN_SIZE*8, (GLfloat)z/TERRAIN_SIZE*8);
glVertex3f(static_cast<GLfloat>(x - TERRAIN_SIZE/2), scaledHeight, static_cast<GLfloat>(z - TERRAIN_SIZE/2));

glColor3f(nextColor, nextColor, nextColor);
glTexCoord2f((GLfloat)x/TERRAIN_SIZE*8, (GLfloat)(z+1)/TERRAIN_SIZE*8);
glVertex3f(static_cast<GLfloat>(x - TERRAIN_SIZE/2), nextScaledHeight, static_cast<GLfloat>(z + 1 - TERRAIN_SIZE/2));
}
glEnd();
}

//draw the water
glBindTexture(GL_TEXTURE_2D, m_waterTexture);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0);
glVertex3f(-TERRAIN_SIZE/2.1f, WATER_HEIGHT, TERRAIN_SIZE/2.1f);

glTexCoord2f(TERRAIN_SIZE/4.0f, 0.0);
glVertex3f(TERRAIN_SIZE/2.1f, WATER_HEIGHT, TERRAIN_SIZE/2.1f);

glTexCoord2f(TERRAIN_SIZE/4.0f, TERRAIN_SIZE/4.0f);
glVertex3f(TERRAIN_SIZE/2.1f, WATER_HEIGHT, -TERRAIN_SIZE/2.1f);

glTexCoord2f(0.0, TERRAIN_SIZE/4.0f);
glVertex3f(-TERRAIN_SIZE/2.1f, WATER_HEIGHT, -TERRAIN_SIZE/2.1f);
glEnd();

}


If I cancel this method the example work OK.
Any idea ?
Which is the error?

With the example 8 happen the same

Advanced thanks


kiko

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!