c++ - glTexImage*D 参数冗余?

标签 c++ opengl

为什么 glTexImage1D、glTexImage2D 和 glTexImage3D 函数需要内部格式(即 GL_RGBA8、GL_R32UI 等)和像素格式? (GL_RGBA,GL_RED_INTEGER)

在我看来,像素格式可以很容易地从内部格式中解释出来。我问这不仅仅是出于好奇,而是因为我要确保我编写的 OpenGL 纹理对象和帧缓冲区对象包装器(从内部格式推断像素格式)能够正确提取所有内部格式的像素格式。

最佳答案

像素格式是您提供纹理数据的格式,内部格式是 OpenGL 在内部存储它的方式。 OpenGL 将自动处理转换。

man page for glTexImage2D有一组很好的内部格式布局表,还解释了每种格式的转换方式。

例如,如果您有像素格式 GL_RG 和内部格式 GL_COMPRESSED_RGBA,GL 会将整个蓝色 channel 填充为 0,将 alpha channel 填充为1,然后自己做内部压缩。

Each element is a red/green double. The GL converts it to floating point and assembles it into an RGBA element by attaching 0 for blue, and 1 for alpha. Each component is then multiplied by the signed scale factor GL_c_SCALE, added to the signed bias GL_c_BIAS, and clamped to the range [0,1].

关于c++ - glTexImage*D 参数冗余?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15121072/

相关文章:

c - OpenGL中鼠标点击改变屏幕面

macos - 在 Mac OSX Lion(10.7) 上设置和使用 OpenGL 3.0+

c++ - 清除 QGraphicsScene : crash 中的小部件

c++ - 为什么我退出循环后我的 map 值被重置

c++ - 3D 相机出现意外滚动

c - OpenGL,第一人称相机翻译

qt - 错误 : couldn't get appropriate GL format for Qt windows

c++ - 使用 SSE 加速浮点 5x5 矩阵 * vector 乘法

c++ - 如何正确使用 std::functional 其他数据类型(在优先队列中)

python - 如何在caffe中创建数据层?