Transparency problem
I am writing a plugin for Maya, which uses OpenGL. This could be a problem with something that Maya is doing but I am not sure. I am trying to draw a polygon that has variable transparency. So far I am able to almost do what I want but not quite. What I want is for my polygon to be able to be fully opaque to fully transparent. What I am getting is a polygon that is about half way opaque to fully transparent. I am loading my texture map with glubyte values of 0 to 255 for the alpha channel. I believe that I am setting something up improperly with blending. Any help would be appreciated.
-Jack
Here is my semi-working code:
GLuint textureName;
glGenTextures(1,&textureName); // get a texture name
glBindTexture(GL_TEXTURE_2D,textureName); // set up that texture
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
// this texture not affected by lighting
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// assign the buffer that I created to the texture
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1024, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, GLbuffer);
delete GLbuffer;
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
// This commented chunk makes the fully transparent areas black.
// The whole texture is opaque with this code
// though and that is not what I want.
// It is my understanding that this is what I really should be doing except
// that it isn't working...
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
// works but seems to have a maximum of 50% transparency
glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement