在我的程序中,我使用了2个纹理:t0和t1。 t1是额外的,只在某些情况下需要使用:
.....
glActiveTexture ( GL_TEXTURE1 );
if ( mDisplayMode == EDM_DEFAULT ){
glBindTexture( GL_TEXTURE_2D, 0 ); // In this case I don't need t1
}else{
glBindTexture( GL_TEXTURE_2D, mglDegreeTexture ); // In this case t1 will overlap t0
}
shader->setUniformValue( "textureId1", 1 );
绘制所需的着色器:
.....
vec4 c1 = texture( textureId0, uv );
vec4 c2 = texture( textureId1, gridUV );
float a = c2.a;
gl_FragColor = ( 1.0 - a )*c1 + a*c2;
它的工作很好:第二个纹理在需要时重叠在第一个上。假设使用glBindTexture(.., 0)返回零纹理(0,0,0,0),但在更新NVidia驱动程序到314.07后,我的代码产生黑屏,就像glBindTexture(.., 0)返回(0,0,0,1)纹理一样。
我进行了一些测试: 使用着色器
....
vec4 c1 = texture( textureId0, uv );
vec4 c2 = texture( textureId1, gridUV );
float a = c2.a;
if (a == 1){
gl_FragColor = vec4(1,0,0,0);
return;
}
if ( a == 0){
gl_FragColor = vec4(0,1,0,0);
return;
}
gl_FragColor = ( 1.0 - a )*c1 + a*c2;
我在旧的驱动程序(296,306)上遇到了绿屏,而在新的驱动程序上则是红屏。我在两台电脑上进行了测试,一台是Win 7(GeForce 210),另一台是win XP(GTX 260)。
因此我的问题是:使用glBindTexture和0作为第二个参数是否正确,并且如何在新驱动程序中实现相同的结果(0000纹理)?