[英]OpenGL: bind at least one texture when working with textures?
我开始在openGl中使用纹理,并且发现一些奇怪的行为。 请参见以下伪代码示例:
int main()...
bindTexture1();
bindTexture2();
bindTexture3();
// None of these textures are actually used!
while(true) {
begin();
// draw stuff
end();
}
我加载并绑定了3个纹理,但现在我只是在绘制图元。 但是这些原语是不可见的。 在以下情况下它们是可见的:
int main()...
bindTexture1(); // <- So the first bind() remains the only one
//bindTexture2();
//bindTexture3();
// None of these textures are actually used!
while(true) {
begin();
// draw again just primitve stuff but now it's visible
end();
}
要么
int main()...
bindTexture1();
bindTexture2();
bindTexture3();
// None of these textures are actually used!
while(true) {
begin();
bindTexture1(); // Binding texture 1 again
// draw again just primitve stuff but now it's visible
end();
}
所以我想我的问题与这个glBindTexture函数有关吗?
在固定管线(opengl 1和2)中渲染2D纹理的过程如下:
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, textureId );
// render
glBegin( GL_QUADS );
glTexCoord2f( 0.0, 0.0 );
glVertex2f( 0.0, 0.0 );
glTexCoord2f( 1.0, 0.0 );
glVertex2f( 1.0, 0.0 );
glTexCoord2f( 1.0, 1.0 );
glVertex2f( 1.0, 1.0 );
glTexCoord2f( 0.0, 1.0 );
glVertex2f( 0.0, 1.0 );
glEnd();
glDisable( GL_TEXTURE_2D );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.