PDA

View Full Version : White Textures :(



31337
04-28-2003, 05:11 PM
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

zeckensack
04-28-2003, 05:40 PM
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\n",pImage->channels);
fprintf(my_pretty_log,"width=%u\n",pImage->width);
fprintf(my_pretty_log,"height=%u\n",pImage->height);
fprintf(my_pretty_log,"components=0x%X\n",Type);
fprintf(my_pretty_log,"data pointer=0x%X\n",(unsigned int)pImage->data);
fclose(my_pretty_log);


See you then ...

evanGLizr
04-28-2003, 05:46 PM
Originally posted by 31337:
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

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.

31337
04-28-2003, 06:04 PM
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...

31337
04-28-2003, 06:08 PM
channels: 3
width: 64
height: 256
Type: 6407 (RGB?)
data pointer: 0x04abbca8

I got those with my debugger. Should still do the job http://www.opengl.org/discussion_boards/ubb/smile.gif

zeckensack
04-28-2003, 07:00 PM
Originally posted by 31337:
channels: 3
width: 64
height: 256
Type: 6407 (RGB?)
data pointer: 0x04abbca8

I got those with my debugger. Should still do the job http://www.opengl.org/discussion_boards/ubb/smile.gifGood. 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.

31337
04-28-2003, 07:19 PM
Nope didn't do it.

31337
04-28-2003, 07:24 PM
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?

roffe
04-28-2003, 08:00 PM
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

31337
04-28-2003, 09:12 PM
Cool I'll check that out.