Archived

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

ftsf

glTexImage2D doesnt work, but gluBuild2DMipmaps does? whats going on.

Recommended Posts

I''m trying to load the textures for a game i''m working on glTexImage2D(GL_TEXTURE_2D, 0, 3, image->w, image->h, 0, GL_RGB, GL_UNSIGNED_BYTE, image->pixels); refuses to work, while gluBuild2DMipmaps(GL_TEXTURE_2D, 3, image->w, image->h, GL_RGB, GL_UNSIGNED_BYTE, image->pixels); works fine.. but for the font bitmap i cant have it mipmapped or it looks blurry, so i need to use the glTexImage2D, can anyone see why it wouldnt be working? thanks.

Share this post


Link to post
Share on other sites
If your image width/height are not power''s of 2 then glTexImage2D will fail. gluBuild2DMipmaps works because it rescales the image to the next largest power of two.

Share this post


Link to post
Share on other sites
thanks but my textures are already powers of two, they''re all
32x32 pixels and the font one is 256x64 i''m pretty certain all of those are powers of two. is there any other reason it might not be working?

Share this post


Link to post
Share on other sites
the common pitfall is NOT to setup the texture filtering.
call that and I bet it will be better :
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

By default it is NEAREST_MIPMAP_LINEAR which means that OpenGL uses mipmaps. But in OpenGL, mipmapping needs *all* mipmap levels, otherwise the texture object is not valid. Hmm.. am I clear ?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Try resizing the font texture to 256 x 256, I think glTexImage2D needs textures to have the same width and height.

Share this post


Link to post
Share on other sites
i dont see how that helps, but thanks anyway.. i fixed the problem (but i dont know how), i went and resaved all my files and now it works for some reason. *still clueless*

Share this post


Link to post
Share on other sites
quote:
I think glTexImage2D needs textures to have the same width and height

false. you can specify any width or height, though if you specify a too small width you may take care of byte alignment. ("too small" is "less than 4").

OpenGL ensures that all implementations support textures up to 64x64, and todays most graphics cards support up to 512x512 without problem. There is no restriction at all about the equality between width and height.

Share this post


Link to post
Share on other sites
And it was not working and all of a sudden it worked ? hmm... weird. I''d say your compiled objects (*.o or *.obj) were not up to date.
I really thought that glTexParameter would help. Sorry.

Share this post


Link to post
Share on other sites