GL_UNSIGNED_BYTE 对 glTexImage2D 意味着什么? [英] What does GL_UNSIGNED_BYTE mean for glTexImage2D?

查看:24
本文介绍了GL_UNSIGNED_BYTE 对 glTexImage2D 意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想加载一个包含 RGBA 8888 格式纹理的字节数组.

OpenGL ES 文档提供了 4 个常量供使用:GL_UNSIGNED_BYTE、GL_UNSIGNED_SHORT_5_6_5、GL_UNSIGNED_SHORT_4_4_4_4 和 GL_UNSIGNED_SHORT_5_5_5_1.

常规 OpenGL 上,有一个值 GL_UNSIGNED_INT_8_8_8_8 可以满足我的需要——这些数字是这样解释的:

<块引用>例如,如果 internalFormat 为 GL_R3_G3_B2,您要求纹素为 3 位红色、3 位绿色和 2 位蓝色.

所以 GL_UNSIGNED_INT_8_8_8_8 必须是 R 的 8 位、G 的 8 位、B 的 8 位和 A 的 8 位.

但是 GL_UNSIGNED_BYTE 在 ES 平台上是什么意思,又会如何解释呢?(R、G、B、A分别是多少位?)

解决方案

GL_UNSIGNED_BYTE 应该使用 GL_RGBA 格式,每个组件提供 8 位.

I want to load a byte array containing a texture in RGBA 8888 format.

The OpenGL ES docs offer 4 constants to use: GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_4_4_4_4, and GL_UNSIGNED_SHORT_5_5_5_1.

On regular OpenGL, there is a value GL_UNSIGNED_INT_8_8_8_8 that meets my needs -- and the numbers are interpreted thus:

For example, if internalFormat is GL_R3_G3_B2, you are asking that texels be 3 bits of red, 3 bits of green, and 2 bits of blue.

So GL_UNSIGNED_INT_8_8_8_8 must be 8 bits of R, 8 bits of G and 8 bits of B and 8 bits of A.

But what does GL_UNSIGNED_BYTE mean on the ES platform and how will it be interpretted? (How many bits are R, G, B and A?)

解决方案

GL_UNSIGNED_BYTE should work with format GL_RGBA, giving 8 bits per component.

这篇关于GL_UNSIGNED_BYTE 对 glTexImage2D 意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆