Jump to content



auxDIBImageLoad memory failer

  • You cannot reply to this topic
2 replies to this topic

#1 SonicMouse   Members   -  Reputation: 122

Like
0Likes
Like

Posted 15 January 2001 - 09:40 PM

anyone have a problem with freeing the memory after calling auxDIBImageLoad ? i have a map that has 7 textures and it loads fine. Then i make a map that has 8 textures and bam i get illeagal ops in the GDI32.DLL when i try to free the memory myself. this is the code:
GLuint Model::LoadGLTexture( const char *filename ){
	AUX_RGBImageRec *pImage;
	GLuint texture = 0;
	pImage = LoadBMP(filename);
	if ( pImage != NULL && pImage->data != NULL ){
		glGenTextures(1, &texture);
		glBindTexture(GL_TEXTURE_2D, texture);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
		gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pImage->sizeX, pImage->sizeY, GL_RGB, GL_UNSIGNED_BYTE, pImage->data);
		free(pImage->data); <-- THIS IS THE LINE
		free(pImage);
	}
	return texture;
}
 
i checked the address of pImage->data and there is legitimate data there. If i remove that line it works great.. but i fear of a tremendeous memory leak if i remove that line for good. could someone tell me if it is necessary to free that data? and if it is, then why does it crash after 7 textures are loaded?

Ad:

#2 Chinglisher   Members   -  Reputation: 100

Like
0Likes
Like

Posted 15 October 2011 - 09:29 PM

I've got the same question.
Anyone can help?

#3 Caste   Moderators   -  Reputation: 931

Like
0Likes
Like

Posted 27 October 2011 - 11:59 PM

Hey guys,
I just posted an update to the texture loading with glaux, as it is really old and actually deprecated.

Lesson 06 Texturing Update

Using this library should fix your problems.
Hope that helps :)







We are working on generating results for this topic
PARTNERS