怎么样`glTexEnv`,`glColor4x`和`在OpenGL ES 1.0的相关glBlendFunc`? [英] How are `glTexEnv`, `glColor4x` and `glBlendFunc` related in OpenGL ES 1.0?
问题描述
我看着SurfaceFlinger的,即在code,它是在做组成Android和我听不太懂一些的OpenGL ES 1.0的调用如我只编ES 2.0 code。
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.
下面那张件code的我感兴趣的:
Here goes the piece of code that interests me:
glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glColor4x(0x10000, 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.
为什么人需要 glTextEnvx
和 glColor4x
电话?是不是 glBlendFunc
够实现混合?
Why does one need the glTextEnvx
and glColor4x
calls? Isn't glBlendFunc
enough for achieving blending?
我的知道的我的问题很幼稚,但我还是不明白什么是 glTexEnvx
,即使读的文档。
I know my question is naive, but I still don't understand what is glTexEnvx
for even after reading the docs.
推荐答案
glTexEnv()
设置纹理环境模式。 GL_REPLACE
告诉渲染器跳过当前颜色(例如,从 glColor4()
),而是告诉渲染器使用纹理的颜色为每个对应的像素。如果是你,而不是 GL_REPLACE
中,使用 GL_MODULATE
,那么你的 glColor4()
的通话将被包含在纹理的颜色放在一起时,渲染器设置一个像素的颜色。
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.
您 glColor4()
通话不应该做任何事情(当使用 GL_REPLACE
),可以看到上你的对象。
Your glColor4()
call shouldn't be doing anything (when using GL_REPLACE
) that can be seen on your object.
关于您的 glBlendFunc()
参数:
GL_ONE
当前使用的颜色来自传入原始的,我们称之为源的。 GL_ONE_MINUS_SRC_ALPHA
是相乘的目标的(这是在帧缓存当前存储像素)由(1 - 源Alpha值)
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).
通常情况下,当你不使用纹理,你实现了从的颜色的原语的透明效果时, glColor4()
包含一个alpha值其中1等于完全不透明和0完全透明。
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.
这篇关于怎么样`glTexEnv`,`glColor4x`和`在OpenGL ES 1.0的相关glBlendFunc`?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!