Archived

This topic is now archived and is closed to further replies.

incubator01

floats

Recommended Posts

in opengl when passign floats I recently had a weird experience: when passing stuff like 0.0 together with some 0.0f I got flicker when passing only 0.0f floats it displayed fine. is there any difference between these 2?

Share this post


Link to post
Share on other sites
0.0 declares a double, while 0.0f declares a float. Your compler is smart enough to know that if a function takes floats and you pass it 0.0 that the argument needs to be converted.

What do you mean by ''flicker''? Could you show your code?

Share this post


Link to post
Share on other sites
the code is from lesson05 NeHe tutorials.
Exactly typed over, except that I typed 0.0 somewhere (in both glVertex3f and gluPerspective instead of 0.0f

the result was that the fron face of the trianlge and quad was not (or partially) drawn and that only the quad flickered (I could see the missing face during this flicker sometimes)

Share this post


Link to post
Share on other sites
numeric post-fixes are more important than many people realize. It''s good practice to always use the "f" postfix for all float data types.

Share this post


Link to post
Share on other sites