Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
    
This question has been answered on Stack Overflow. –  Bartek Banachewicz Jul 18 '13 at 14:55

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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