OpenGL glGetTexImage2d 类型参数?

发布于 2024-08-07 10:34:50 字数 227 浏览 5 评论 0原文

阅读文档我发现 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

执妄 2024-08-14 10:34:50

每个通道都是一个 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).

只想待在家 2024-08-14 10:34:50

type 参数指定发送到 OpenGL 的缓冲区内数据的有效类型。

这里的目的是 OpenGL 将在您的缓冲区中行走,并想知道存在多少元素( width * height * insideformat )及其大小和大小。解释(类型)。

例如,如果您要提供包含红/绿/蓝/alpha 通道(按此顺序)的无符号整数数组,则需要指定:

  • targetGL_TEXTURE_2D
  • level: 0 (除非您使用 mipmap)
  • internalformat: 4 因为您有红色、绿色、蓝色和 alpha
  • width: 640
  • < code>height: 480
  • border: 0
  • internal 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 alpha
  • width: 640
  • height: 480
  • border: 0
  • internal format: GL_RGBA to tell opengl the order of our channels, and what they mean
  • type: GL_UNSIGNED_INT will let opengl know the type of elements inside our array
  • pixels: a pointer to your array
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文