• Advertisement

Archived

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

How do I get GL_ALPHA textures to work?

This topic is 6578 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I try and try but I don''t get it to work. Well, here''s what you should know in order to answer my question :
glBindTexture2D(GL_TEXTURE_2D, texID);
//set texture environment variables, and stuff like that
glTexImage2D(GL_TEXTURE_2D, 0, 1, imgWidth, imgHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pImage);
// the image (1 alpha-channel = 1 byte) is stored in pImage
 
Now if I try to draw a texturemapped quad with the mentioned texture, all I get is a blank rectangle. What else do I need to do? Do I have to enable blending or any other stuff like that? Any help would be appreciated. Thank you.

Share this post


Link to post
Share on other sites
Advertisement
Done it!
AlI I had to do was just replacing
glTexImage2D(GL_TEXTURE_2D, 0, 1, imgWidth, imgHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pImage);
with
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, imgWidth, imgHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, pImage);
Don't ask me why, because theMSDN Library that comes with Visual C++ says that the third parameter should be the number of bytes per pixel.
Quoting the MSDN Library :
void glTexImage2D(GLenum target,GLint level,GLint components ,GLsizei width,GLsizei height,GLint border,GLenum format,GLenum type,const GLvoid *pixels);
....
components
The number of color components in the texture. Must be 1, 2, 3, or 4.


Edited by - chappa on 1/17/00 3:47:15 PM

Share this post


Link to post
Share on other sites

  • Advertisement