glTexImage2D

Started by
3 comments, last by timmie 21 years, 8 months ago
Hello. I''m having a problem with glTexImage2D(). It doesn''t seem to be generating the texture like you''d expect. I''m passing it an 8*8 4 channel image, but when I use the texture, it just comes out white (or untextured). gluBuild2DMipmaps() works properly, though... ie: glBindTexture(GL_TEXTURE_2D, tex); gluBuild2DMipmaps(GL_TEXTURE_2D, 4, _width, _height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); //this works glBindTexture(GL_TEXTURE_2D, tex); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _width, _height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer); //this doesn''t I want to use glTexImage2D() because it is *much* faster and I''m not using the mipmaps from that texture anyway... I''m also not getting any errors from OpenGL (via glGetError()). Any suggestions?
Advertisement
I had the same problem(http://www.gamedev.net/community/forums/topic.asp?topic_id=104234), but it turned out it was because the image i used wasnt the right size(ie a power of 2), you see the mipmap method scales the image before it calls all the glTexImage2D.
But if you are sure the image is 8x8 then i dont know what the problem could be.
Have you set filter settings for the texture?
For example:
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
I had some problems with disappearing textures when these werent set too.

Dont value my advice too high though, im a newbie to OpenGL.
8x8 is too small, most cards support 16x16 as the smallest size of a base mip level.

------------
- outRider -
glTexSubImage2D() is faster than glTexImage2D by ALONG shot, certainly on Nvidia cards, and I assume the same can be said for ATi''s
quote:
glTexSubImage2D() is faster than glTexImage2D by ALONG shot, certainly on Nvidia cards, and I assume the same can be said for ATi''s

Use glTexImage2D to create a texture, and glTexSubImage2D to update it.

quote:
8x8 is too small, most cards support 16x16 as the smallest size of a base mip level

No, any size down to 1x1 is supported as a base level. This is independent of mipmapping.

timmie:
1) make sure that _width and _height are both powers of two.
2) make sure you have disabled mipmapping: the MIN filter must not be set to one of the mipmapping modes.

This topic is closed to new replies.

Advertisement