Can anybody tell me how exactly to use GL_INT_2_10_10_10_REV as type parameter in glVertexAttribPointer()?

I am trying to pass color values using this type. What is the significance of "REV" suffix in this type? Does it require any special treatment in the shaders?


GL_INT_2_10_10_10_REV is a packed integer data type. Elements of this type in a buffer need 32 bits of space, with the Z, Y, and X (or B, G and R) components packed respectively into ten bit chunks starting at the low bits (that is, Z is bits 0 through 9, Y is bits 10 through 19, et cetera). The W (or A) component is stored in the high two bits (30 and 31).

The "REV" suffix refers to the fact that the data is "reversed," because the Z component is stored in the least significant bits.

This format allows higher precision in the XYZ/RGB channels at the cost of precision in the W/A channel. The pipeline will unpack the channel data and apply normalization back to [-1, 1] ([0, 1] for the unsigned variant) if you ask for it (using the normalized parameter of glVertexAttribPointer). Other than that, and deciding in your shaders to accept them as normalized floating point values or their original fixed-point integer values, they should not require special handling.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.