OpenGL texture upload: UNSIGNED_BYTE vs UNSIGNED_INT_8_8_8_8

前端 未结 1 2003
北海茫月
北海茫月 2021-02-14 06:29

I\'m calling glTexSubImage2D. If my pixel format is GL_RGBA, then are the pixel types GL_UNSIGNED_BYTE and GL_UNSIGNED_INT_8_8_8_8 fully e

相关标签:
1条回答
  • 2021-02-14 07:10

    The answers are No and No. You have to think about the byte order in your computer. If you have GL_RGBA and GL_UNSIGNED_INT_8_8_8_8, that means that pixels are stored in 32-bit integers, and the colors are in the logical order RGBA in such an integer, e.g. the red is in the high-order byte and the alpha is in the low-order byte. But if the machine is little-endian (as with Intel CPUs), it follows that the actual order in memory is ABGR. Whereas, GL_RGBA with GL_UNSIGNED_BYTE will store the bytes in RGBA order regardless whether the computer is little-endian or big-endian.

    GL_BGRA with GL_UNSIGNED_INT_8_8_8_8_REV would store colors in an integer in the logical order ARGB, but then on a little-endian machine, you get BGRA order in memory.

    0 讨论(0)
提交回复
热议问题