View Full Version : Using variables...
05-09-2004, 12:24 PM
In functions like glColor4f(), how can I use variables? (because you have to use a number between 0 and 1.0 with f stuck to the end of it.
Just pass the variable containing the value to glColor4f.
GLfloat foo = 0.2;
glColor4f(foo, 0.3, 0.4, 1);
Do we really need the 'f' stuck at the end?
05-09-2004, 01:12 PM
Apperantly we don't.
Well, that speeds up production time, ohh, %1000.
05-09-2004, 05:19 PM
actually, on some compilers [visual studio c++ 6.0] you have to append the 'f' otherwise the compiler complains. gcc suite doesn't.
it might be annoying, [and not to be a troll] but what slashdot'd said is true - compilers will make a float out of a number with an 'f' appended, versus them automatically[?] making floating-point numbers double...
just a thought...
05-09-2004, 11:22 PM
there are other number formates for example
Where ub is unsigned bit(or byte, i think) and is from 0-255 and d is int but not sure of its range.
So no you dont always need the f, but it would be better for the program if you could tell it that as it wouldnt have to guess, eventually something bad might happen.
At least that what i think and understand.
05-09-2004, 11:50 PM
The appended f tells the compiler that the number you intend to create in memory is a single precision float. This is ANSI C and nothing to do with OpenGL. Also of course you can use a variable as the float argument.
You need to get a book on basic C programming, these questions are not OpenGL questions.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.