Opengl 纹理和字节顺序
我使用 glTexSubImage2D 与 GL_LUMINANCE 和 GL_UNSIGNED_BYTE 直接显示来自相机的原始灰度数据 - 而不必手动将其重新打包为 RGB 位图。
我想以更高分辨率模式运行相机,即 12 或 14 位/像素。
我可以简单地通过设置 GL_SHORT 来做到这一点,但相机以大尾数法返回数据,而我的 openGL 实现似乎以错误的方式绘制它(在 x86 上)。
有没有一种简单的方法告诉 openGL 纹理是“错误”的?我想避免仅仅为了显示而手动字节交换数据,因为所有其他函数都需要大端数据。
I'm using glTexSubImage2D with GL_LUMINANCE and GL_UNSIGNED_BYTE to display raw greyscale data from a camera directly - rather than having to repack it into an RGB bitmap manually.
I would like to run the camera in higher resolution mode, with 12 or 14bits/ pixel.
I can do this with simply by setting GL_SHORT
but the camera returns data in big endian and my openGL implementation seems to be drawing it the wrong way around (on x86).
Is there a simple way of telling openGL that the textures are the 'wrong' way round? I would like to avoid manually byteswaping the data just for display because all the other functions expect big endian data.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 glPixelStore* 函数组。
您可能需要使用
GL_UNPACK_SWAP_BYTES
或GL_UNPACK_LSB_FIRST
,但请仔细检查您使用的GL_UNPACK_ALIGNMENT
是否正确。默认情况下,解压对齐为 4,但如果您使用每个像素一个字节 (lum / ub),则需要将其设置为 1。我最近遇到了这个问题,我花了更长的时间才弄清楚比我愿意承认的:)Check out the glPixelStore* group of functions.
You might need to play with
GL_UNPACK_SWAP_BYTES
orGL_UNPACK_LSB_FIRST
but double check you're using the correctGL_UNPACK_ALIGNMENT
. By default the unpack alignment is 4, but if you're using one byte per pixel (lum / ub), you'll want to set that to 1. I ran into this problem just recently, and it took me longer to figure out than I'd care to admit :)