White Textures :(

I’m having a serious problem with my texturing class. gluBuild2DMipmaps() fails and when I check the error it says its “out of memory” and when I try to use glTexImage2D instead it gives me GL_INVALID_ENUM or something like that. Whats the deal you guys?

I am 100% I am not actually “out of memory” and it says it on the first texture. The parameters look like this:

gluBuild2DMipmaps(GL_TEXTURE_2D, pImage->channels, pImage->width, pImage->height, Type, GL_UNSIGNED_BYTE, pImage->data);

and I’ve checked em all out and they seem fine. As a result I just get blank textures (white). I’ve posted this at gamedev and they are stuck too. Any help would be appreciated. Thanks

gluBuild2DMipmaps(GL_TEXTURE_2D, pImage->channels, pImage->width, pImage->height, Type, GL_UNSIGNED_BYTE, pImage->data);
Gawd …

Care to tell us what values these vars are?

Tell you what, insert a debugging log into that application and dump the vars out just before calling TexImage.

Ie

FILE* my_pretty_log=fopen("my_pretty_log.txt","w");
fprintf(my_pretty_log,"internal format=0x%X
",pImage->channels);
fprintf(my_pretty_log,"width=%u
",pImage->width);
fprintf(my_pretty_log,"height=%u
",pImage->height);
fprintf(my_pretty_log,"components=0x%X
",Type);
fprintf(my_pretty_log,"data pointer=0x%X
",(unsigned int)pImage->data);
fclose(my_pretty_log);

See you then …

Originally posted by 31337:
[b]I’m having a serious problem with my texturing class. gluBuild2DMipmaps() fails and when I check the error it says its “out of memory” and when I try to use glTexImage2D instead it gives me GL_INVALID_ENUM or something like that. Whats the deal you guys?

I am 100% I am not actually “out of memory” and it says it on the first texture. The parameters look like this:

gluBuild2DMipmaps(GL_TEXTURE_2D, pImage->channels, pImage->width, pImage->height, Type, GL_UNSIGNED_BYTE, pImage->data);

and I’ve checked em all out and they seem fine. As a result I just get blank textures (white). I’ve posted this at gamedev and they are stuck too. Any help would be appreciated. Thanks[/b]

I assume you have checked that all the parameters are correct (valid pointers, image width and height sensible and below your card’s allowed, etc).

My guess is that you’ve probably trashed your memory allocator structures (new/malloc internal structures), so the allocator believes it doesn’t have enough memory and returns NULL to gluBuildMipmaps.

Getting white rendering instead of textured is almost always the result of having an “incomplete texture state” (i.e. you are using a mipmap filter without having defined all the mipmap levels). If your texturing state is incomplete, OpenGL mandates that images should be rendered as if texturing was disabled.

My gut feel is that if you use a minification filter that doesn’t require mipmaps, you might be able to see some kind of texturing going on (although that won’t fix your problem).

Review your code looking for places where you free a pointer twice, write more data than you have allocated space for, use delete/ new instead of delete/new, etc.

Ok I’ll give you a log of the variables I’m passing it. I actually am having a problem with freeing memory twice. When I hit escape my program beeps (i’m guessing its a memory error) and I’ve tried like the devil to find the problem but I can’t. Does anybody have any suggestions on how? Let me get you that log…

channels: 3
width: 64
height: 256
Type: 6407 (RGB?)
data pointer: 0x04abbca8

I got those with my debugger. Should still do the job

Originally posted by 31337:
[b]channels: 3
width: 64
height: 256
Type: 6407 (RGB?)
data pointer: 0x04abbca8

I got those with my debugger. Should still do the job [/b]
Good. 6407 is GL_RGB. 3 is not quite GL_RGB, but very close (still allowed for backward compatibility AFAIR).

Try assigning GL_RGB instead of 3. I wouldn’t expect that to be the problem, but it can’t hurt to try.

Nope didn’t do it.

My program is having some freaky crashing issues on exit. I’m looking into them. Is there an easy way to find memory leaks and such?

Originally posted by 31337:
Is there an easy way to find memory leaks and such?

There are many ways. I guess Purify is one of the better tools. It takes some time to learn how to use it though. Personally I like CMemLeak. It is very simple. I link to it in debug builds.
http://www.codeguru.com/misc/CMemLeak.html

Cool I’ll check that out.