Archived

This topic is now archived and is closed to further replies.

mpGLTextures should be null

This topic is 5094 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

Here is the code I am using to delete mpGLTextures. mpGlTextures is in fact NULL (I''ve checked using assert and _ASSERTE). I don''t understand why it is trying to delete something that is already NULL. mpGLTextures is set to null in my constructor code. I believe I am having memory problems elsewhere in my program to be honest. Here is the code, does anybody have any ideas?
//	_ASSERTE(mpGLTextures); //Says mpGLTextures is NULL
	
	/*if(mpGLTextures == NULL)	//This also says mpGLTextures is NULL
	{
		trace << "mpGLTextures == NULL" << "\n";
		return;
	}
	*/
	if(mpGLTextures)
	{
		glDeleteTextures(mNumTextures,mpGLTextures);
		if(mpGLTextures)
		{
			delete[]	mpGLTextures;
			mpGLTextures = NULL;
		}
		mNumTextures	=	0;
	}
 
Any help would greatly be appreciated.

Share this post


Link to post
Share on other sites
Yes, and it tells me that the program is failing here:

if(mpGLTextures)

The thing I do not understand is that if mpGLTextures is null, it should simply not run the if statement, not crash. I am very confused, I am using various things to track the problem i.e crtCheckMemory and assert but I do not know what I am doing wrong. Perhaps I coded something wrong in the destructor? (I didn't post the destructor/constructor code because it is lengthy, but I can post it if I need to).



[edited by - Shadow12345 on February 6, 2004 10:58:39 AM]

Share this post


Link to post
Share on other sites
Ah, that's something new. You didn't say it was crashing.

Probably the object that this function is called on is invalid. What value is the this pointer?

[edited by - petewood on February 6, 2004 11:07:24 AM]

Share this post


Link to post
Share on other sites
I''m sorry for being so vague. I believe I have found the problem after you told me to check for the value in the this pointer. It was in fact zero...I was deleting the object and setting it to NULL in one function, but then trying to reload it in another function without calling NEW on it again. I really feel silly right now. i''m still having problems in other areas, but that''s because I need to clean up my memory allocated by some external std::vectors. Thank you for bumping me in the correct direction

I feel silly lol

Share this post


Link to post
Share on other sites