How are `glTexEnv`, `glColor4x` and `glBlendFunc` related in OpenGL ES 1.0?
I'm looking at SurfaceFlinger, i.e. the the code that is doing the composition in Android, and I have trouble understanding some of the OpenGL ES 1.0 calls as I've only programmed ES 2.0 code.
Here goes the piece of code that interests me:
glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glColor4x(0x开发者_如何学C10000, 0x10000, 0x10000, 0x10000);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
What it is supposed to be doing is blending a texture into the buffer.
Why does one need the glTextEnvx
and glColor4x
calls? Isn't glBlendFunc
enough for achieving blending?
I know my question is naive, but I still don't understand what is glTexEnvx
for even after reading the docs.
glTexEnv()
sets the texture environment mode. GL_REPLACE
tells the renderer to skip the current color (for example, from glColor4()
) and instead tells the renderer to use your texture's colors for every corresponding pixel. If you, instead of GL_REPLACE
, use GL_MODULATE
, then your glColor4()
call will be included together with the texture's colors when the renderer sets a pixel's color.
Your glColor4()
call shouldn't be doing anything (when using GL_REPLACE
) that can be seen on your object.
About your glBlendFunc()
arguments:
GL_ONE
is using the current color that comes from your incoming primitive, which we call source. GL_ONE_MINUS_SRC_ALPHA
is multiplying the destination (which is the currently stored pixel in the frame buffer) by (1 - source alpha value).
Normally, when you're not using textures, you achieve a transparent effect from color primitives when the glColor4()
contains an alpha value where 1 equals fully opaque and 0 fully transparent.
精彩评论