问题
I have a texture from this PNG:

And another from this PNG:

They both have the same blend function:
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
I want to see them on one single polygon first. I just couldn't find a simple example of this. Draw them to different polygons works perfect, but I just cannot "merge" them into one texture. Any working sample codelines would be appreciated well.
Second problem is to make the specular map's alpha variable. I can see that I have to texture combine somehow it's alpha with the primary color (created from my variable), but again, have no working example of codes. I began to study glTexEnvi function, but yet I have no any result.
Please, I beg you for just about 16 lines of code! I googled the whole net, but still stuck.
The engine I want to implement (working flash sketch on the bottom of the post) is here.
回答1:
I don't know the exact lines of code that you need, but it seems that you were on the right path with glTexEnv... This book on opengles 1.1 talks about it some. I think what you want are texture combiners:
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, myTextureObject);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
// Tell OpenGL which arithmetic operation to use:
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, <operation>);
// Set the first argument:
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, <source0>);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, <operand0>);
// Set the second argument:
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, <source1>);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, <operand1>);
I don't know if this will accomplish what you want though, you may still need the FBOs to do it right.
来源:https://stackoverflow.com/questions/2173363/opengl-es-iphone-multi-texturing-2d-code