Using variables...

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?

Apperantly we don’t.
Well, that speeds up production time, ohh, %1000.

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…

:regards:

there are other number formates for example
glColor3ub(255,255,255);
glColor3d(1,1,1);

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.

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.