posts - 25,  comments - 21,  trackbacks - 0


//获取shader里面uniform变量的地址
int tex1_location=glGetUniformLocation(m_uProgram, "tex1");
int tex2_location=glGetUniformLocation(m_uProgram, "tex2");
int tex3_location=glGetUniformLocation(m_uProgram, "tex3");

//对这几个纹理采样器变量进行设置
glUniform1i( (GLint)tex1_location, 0);//对应纹理第一层
glUniform1i( (GLint)tex2_location, 1);//对应纹理第二层
glUniform1i( (GLint)tex3_location, 2);//对应纹理第三层

//后面渲染的时候,设置三成纹理
 glActiveTexture(GL_TEXTURE0 + 0);
 glBindTexture(GL_TEXTURE_2D, texture1Id);
 
 glActiveTexture(GL_TEXTURE0 + 1);
 glBindTexture(GL_TEXTURE_2D, texture2Id);
 
 glActiveTexture(GL_TEXTURE0 + 2);
 glBindTexture(GL_TEXTURE_2D, texture3Id);
 
 //所以glActiveTexture第几层,并不表示是shader里面第几个采样器,
 //中间有glUniform1i进行纹理层和采样器地址进行绑定
posted on 2014-07-08 10:27 Sherk 阅读(2676) 评论(0)  编辑 收藏 引用
只有注册用户登录后才能发表评论。
<2014年7月>
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

常用链接

留言簿(3)

随笔档案

相册

好友

搜索

  •  

最新评论

阅读排行榜

评论排行榜