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.
How do I get GL_ALPHA textures to work?
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 :
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement