OpenGL variable image transparency
Posted: Wed Sep 14, 2005 8:46 pm
This line demonstrates the problem:
The image is either not drawn at all (alpha of 0) or with the full opacity from the texture (alpha 1-255).
After playing around with the engine source a bit, and searching through the net I found the original code from zola, and saw a difference in the "setRenderStates2DMode"-function.
zola's original code (only the relevant part):
...and the code currently in Irrlicht:
I don't know much about OpenGL so I can't tell what the new code was supposed to fix, but I replaced it with the old one, and lo and behold, the alpha issue is gone.
Makes a pretty good workaround obsolete that I already wrote...
Could someone with OpenGL experience please look this through? I doubt that the code was changed without reason, so I fear I may be trading one evil for another.
MedO
Code: Select all
itsDriver->draw2DImage(itsImage, pos, itsSourceRect, 0, video::SColor(alpha,255,255,255), true);
After playing around with the engine source a bit, and searching through the net I found the original code from zola, and saw a difference in the "setRenderStates2DMode"-function.
zola's original code (only the relevant part):
Code: Select all
if (alphaChannel)
{
glEnable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
Code: Select all
if (alphaChannel)
{
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE);
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_TEXTURE);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT);
}
Makes a pretty good workaround obsolete that I already wrote...
Could someone with OpenGL experience please look this through? I doubt that the code was changed without reason, so I fear I may be trading one evil for another.
MedO