OpenGL ES(iPhone)多重纹理(2D)代码 [英] OpenGL ES (iPhone) multi-texturing (2D) code
问题描述
我有这个PNG的纹理:
I have a texture from this PNG:
还有这个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.
第二个问题是制作高光贴图的alpha变量.我可以看到,我必须对Alpha和原色(通过我的变量创建)进行某种方式的纹理组合,但是仍然无法正常工作代码示例.我开始研究glTexEnvi函数,但没有任何结果.
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.
请求求您大约16行代码!我在整个网络上用Google搜索,但仍然卡住了.
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.
推荐答案
我不知道您需要的确切代码行,但似乎使用glTexEnv的方向正确. ="http://iphone-3d-programming.labs.oreilly.com/ch08.html" rel ="nofollow">有关opengles 1.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>);
我不知道这是否能满足您的要求,您可能仍然需要FBO来正确完成.
I don't know if this will accomplish what you want though, you may still need the FBOs to do it right.
这篇关于OpenGL ES(iPhone)多重纹理(2D)代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!