OpenGL:使用纹理时至少绑定一个纹理
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 );
相关文章:
- 如何创建一个CMake变量,除非显式重写,否则使用默认值
- 删除一个线程上有数百万个字符串的大型哈希映射会影响另一个线程的性能
- OpenGL 2D游戏只绘制第二个精灵纹理而不是第一个
- 如何在单独的线程上加载纹理到主内存并使用它在另一个线程上渲染
- 读写一个纹理(OpenGL)
- 如何在OpenGL中编写一个类或函数来自动分配纹理单元
- 将绑定到FBO的纹理复制到另一个OpenGL上下文
- 仅显示一个纹理
- 如何绘制一个所有面都有不同纹理的立方体
- 在多个四边形上拉伸一个纹理
- 为渲染对象的所有实例维护一个指向共享纹理/资源的指针/引用的最佳方式
- 渲染一个纹理到一个窗口
- 一个在SDL2, c++中旋转纹理的方法
- OpenGL/ c++将所有纹理资源作为静态成员存储在一个单独的类中
- 如何解除对RenderTarget纹理的绑定,这样它就可以被用作下一个通道的输入
- 通过原始缓冲区数据缩放和旋转纹理到另一个纹理上
- OpenGL -最简单的方法来绘制一个正方形与纹理
- OpenGL:使用纹理时至少绑定一个纹理
- 如何将纹理从一个设备复制到另一个设备
- 我如何得到一个GLuint纹理的宽度