Jump to content

  • Log In with Google      Sign In   
  • Create Account

How do I get GL_ALPHA textures to work?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Chappa   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 January 2000 - 08:17 AM

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.

Sponsor:

#2 Chappa   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 January 2000 - 09:42 AM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS