Meaning of: GLfixed frame_speed = (1 16)

Started by
2 comments, last by bunkai 14 years, 7 months ago
Dear Everybody, I try to understand OpenGL ES, but this line does not make sense to me, even after reading C++ help. GLfixed frame_speed = (1 << 16); Can anybody help to explain, please. GLfixed should be 32 bit fixed point interger having format (s15.16). Regards, Rene [Edited by - bunkai on September 12, 2009 1:39:41 PM]
Advertisement
I assume thats just a 'easier' way of writing that number, I often do similar things eg

x += (8*16 + 8);
I could of writen 136 but writing (8*16 + 8) perhaps makes it clearer why the number comes to 136
Its because of the GLfixed format. That line appears to be saying that it wants the "frame_speed" to be equal to 1. If you just had the line

GLfixed frame_speed = 1;

Then it wouldn't actually be equal to 1 instead it would be equal to (1>>16).
Therefore to get the correct fixed-point value you must shift it along to the correct place within the 32bit field, which is why you have:

GLfixed frame_speed = (1 << 16);


http://en.wikipedia.org/wiki/Fixed-point_arithmetic

Andy

"Ars longa, vita brevis, occasio praeceps, experimentum periculosum, iudicium difficile"

"Life is short, [the] craft long, opportunity fleeting, experiment treacherous, judgement difficult."

Dear Zedz, Andy,

Thank you both for explanation. Now it is clear to me.

With best regards,
Rene

This topic is closed to new replies.

Advertisement