texturing problem


I want to change my program from gluBuild2DMipmaps to SGIS_GENERATE_MIPMAP but somehow it doesn’t work and I can’t see why.

For testing purposes the texture the min and mag filters are set to GL_NEAREST.

In fact the problem seems to be that glTexImage2d(…) does not work. The old, working code is:

gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, width, height, GL_RGBA, GL_UNSIGNED_BYTE, Image);

and everything looks fine. When changing this to

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, Image);

there are no textures anymore. I thought that maybe OpenGL needs every mipmap level down to 1x1 to be defined (although i do not really think so due to examples in the red book that work without further mipmap levels), so i changed the min and mag filters to GL_NEAREST (as mentionend above). Then, i added the line


assuming that this would at least generate the neccessary mipmap levels, but still, no textures. And I cannot see what is wrong with the glTexImag2d(…) call… Can someone please help?


some hours passed and no one answered… i start to get depressed and in panic… please help someone…

Why do you use NEAREST filtering and ask GL to mipmap them?

Set the minification to GL_LINEAR_MIPMAP_LINEAR and mag to GL_LINEAR and then use automatic mipmaping.

And make sure the dimensions are power of 2.

if(width % 2!=0) error!!!
if(height % 2!=0) error!!!

i set the filters to NEARES to DISABLE mipmapping for testing if at least glTexImage2d works.

But I think the other thing you said with the powers of 2 might be an important hint, as the textures are NOT sized that way… I think gluBuild2DMipmaps however works with that and resizes the tex images before calling glTexImage… At least I read somewhere that gluBuild2DMipmaps can handle textures that are not sized that way. Maybe glTexImage cannot and because of that, there are no textures? Simple solution but hard to work around as there are very much textures…


Originally posted by V-man:

And make sure the dimensions are power of 2.
if(width % 2!=0) error!!!
if(height % 2!=0) error!!!

Wow, very solid code indeed. Next please.