OpenGL glGetTexImage2d 类型参数?
阅读文档我发现 glGetTexImage2d() 函数有一个“类型”参数。 文档说类型参数“指定像素数据的数据类型”并给出了一些类型的示例,例如 GL_INT、GL_BYTE 等。
但是当图像格式为 GL_RGBA 和 GL_INT 时,它到底意味着什么?每个通道都是一个整数吗?或者整个颜色的整数?如果它是整个颜色的 int ,那么这不是和 GL_BYTE 一样吗?因为 int 有 4 个字节,这使得每个通道各一个字节
reading the docs i see that the glGetTexImage2d() function has a 'type' parameter.
The docs say that the type parameter "specifies the data type of the pixel data" and gives some examples of types such as GL_INT, GL_BYTE, etc.
but what does it mean precisely when the image format is GL_RGBA and GL_INT ? is it an int for each channel? or an int for the whole color? and if it's an int for th whole color, then isn't that really the same as GL_BYTE ? since there's 4 bytes in an int which makes each channel a byte each
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
每个通道都是一个 int。 RGBA 意味着每个像素在您提供的数据数组中都有 R、G、B 和 A 整数(如果将其设置为 int)。 RBGA(如果存在,不确定)也意味着四个整数,但顺序不同。 RGB 意味着只有三个(没有 Alpha 通道)。
It's an int per channel. RGBA means each pixel has R, G, B and A ints (if you set it to int) in the data-array you're giving it. RBGA (if it exists, not sure of that) would also mean four ints, but ordered differently. RGB would mean just three (no alpha channel).
type 参数指定发送到 OpenGL 的缓冲区内数据的有效类型。
这里的目的是 OpenGL 将在您的缓冲区中行走,并想知道存在多少元素(
width * height * insideformat
)及其大小和大小。解释(类型
)。例如,如果您要提供包含红/绿/蓝/alpha 通道(按此顺序)的无符号整数数组,则需要指定:
target
:GL_TEXTURE_2D
level
: 0 (除非您使用 mipmap)internalformat
: 4 因为您有红色、绿色、蓝色和 alphawidth
: 640border
: 0internal format
: GL_RGBA 告诉 opengl 我们通道的顺序,以及它们的含义type
>:GL_UNSIGNED_INT
会让opengl知道我们数组中元素的类型pixels
:指向数组的指针The type parameter specifies the effective type of the data inside the buffer you're sending to OpenGL.
The aim here is that OpenGL is going to walk in your buffer, and want to know how much elements are present (
width * height * internalformat
) and their size & interpretation (type
).For instance, if you are to provide an array of unsigned ints containing red/green/blue/alpha channels (in this order), you'll need to specify:
target
:GL_TEXTURE_2D
level
: 0 (except if you use mipmaps)internalformat
: 4 because you have red, green, blue and alphawidth
: 640height
: 480border
: 0internal format
: GL_RGBA to tell opengl the order of our channels, and what they meantype
:GL_UNSIGNED_INT
will let opengl know the type of elements inside our arraypixels
: a pointer to your array