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.

glVertexAttribPointer(index, size, type, normalized, stride, pointer);

If I use type=GL_UNSIGNED_BYTE and normalized=GL_TRUE

how is it normalized? would the data be divided by 256 for normalization? or? This would mean there is no way to have a normalized value of '1.0f'..

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

From the manual,

If set to GL_TRUE, normalized indicates that values stored in an integer format are to be mapped to the range [-1,1] (for signed values) or [0,1] (for unsigned values) when they are accessed and converted to floating point.

I take that to mean that, with an unsigned 8 bit type, 0 would map to 0.0f and 255 would map to 1.0f.

share|improve this answer
    
So that means it is divided by 255? –  Jonathan Apr 8 '11 at 21:58
    
Right, unsigned byte has range of 0 - 255. So if you passed 0xFF (which is equal to 255), you'd get 1.0f. –  stephelton Apr 8 '11 at 22:09
2  
... Did you ever play the original Zelda? The maximum amount of rubies you could hold was 255, not 256 ;) –  stephelton Apr 8 '11 at 22:12
    
I know that unsigned bytes only go to 255.. I was just wondering because it seemed logic for the GPU to divide by a power-of-two –  Jonathan Apr 8 '11 at 23:23
    
I was wondering something similar. There may be an efficient conversion from uint_8 to float that doesn't do much more than shifting bits around, but I'm not the one to ask... Someone who knows more about FPU's might chime in? –  stephelton Apr 9 '11 at 0:05
add comment

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.