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

Started by
8 comments, last by ftsf 21 years, 2 months ago
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.
Advertisement
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.
---I write code.DelphiGL (http://delphigl.cfxweb.net)
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?
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 ?
Try resizing the font texture to 256 x 256, I think glTexImage2D needs textures to have the same width and height.
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*
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.
Did you call glTexParameter with GL_TEXTURE_MIN_FILTER or GL_TEXTURE_MAG_FILTER ?
yes i did
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.

This topic is closed to new replies.

Advertisement