在我的程序中,我使用 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)上得到绿屏,在新驱动程序上得到红屏。我在 2 台装有 Win 7 (GeForce 210) 和 win XP (GTX 260) 的计算机上对其进行了测试。
所以我的问题是:使用 0 作为第二个参数的 glBindTexture 是正确的,以及如何使用新驱动程序实现相同的结果( 0000 纹理)?