//获取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 阅读(2692)
评论(0) 编辑 收藏 引用