1. ## Primaries: OpenGL

Ok, there is a line i am worried about in this small exerpt of a opengl tutorial i am reading. I have bolded it so that you know what i am referring to, but left the context around it so it made sense. I don't believe i learned these, can someone explain what hes talking about and how i could learn them? I will admit i am quite confused at the moment but i'm ok so far. If it helps the whole tutorial is here

The following line sets the color of the screen when it clears. If you don't know how colors work, I'll quickly explain. The color values range from 0.0f to 1.0f. 0.0f being the darkest and 1.0f being the brightest. The first parameter after glClearColor is the Red Intensity, the second parameter is for Green and the third is for Blue. The higher the number is to 1.0f, the brighter that specific color will be. The last number is an Alpha value. When it comes to clearing the screen, we wont worry about the 4th number. For now leave it at 0.0f. I will explain its use in another tutorial.

You create different colors by mixing the three primary colors for light (red, green, blue). Hope you learned primaries in school. So, if you had glClearColor(0.0f,0.0f,1.0f,0.0f) you would be clearing the screen to a bright blue. If you had glClearColor(0.5f,0.0f,0.0f,0.0f) you would be clearing the screen to a medium red. Not bright (1.0f) and not dark (0.0f). To make a white background, you would set all the colors as high as possible (1.0f). To make a black background you would set all the colors to as low as possible (0.0f).

2. He just means the main colors from where all colors can be mixed
Red,Green and Blue, blue and red for instance are combined
purple, i sure hope youve learned this already

3. Code:
`glClearColor(0.5f,0.0f,0.0f,0.0f)`
Just a note:
Why all these f after the numbers? I know what they are for (denote floating-point format), but in this case they seem superfluous and cluttering.
I've seen this in lots of OpenGL code.

4. Actually the primary colors are red, yellow, and blue...

RoD, you're starting to learn OpenGL too? I've just started using the tutorials at www.gametutorials.com and I've made one program so far. Check it out at www.geocities.com/napKINfolk/Main.html
. Also, there is a book I think I'm gonna buy from Amazon. It looks very good for beginner OpenGL programmers.

//napKIN

5. Originally posted by napkin111
Actually the primary colors are red, yellow, and blue...
Not in light. Light it's Red, Green and Blue.

6. Originally posted by Travis Dane
He just means the main colors from where all colors can be mixed
Red,Green and Blue, blue and red for instance are combined
purple, i sure hope youve learned this already
oh ok, thnx man i get it now.

Napkin: My bud in my programming class is giving me that book for free because he decided to get into apps programming ^_^

7. Yeah when you have lighting you can enable color tracking so whenever you set color of an object in opengl you are also setting the material properties, i.e what light the object reflects. I wouldn't get too worried about the exactly mixing of colors in opengl. If you want more precision (meaning a wider range of colors) you can use glColor3ub, it uses an unsigned byte meaning values 0 through 255 for each red green and blue.

8. ACK! He's giving you that book?? I'll buy it from you... Why would anyone want to do apps programming??

//napKIN

9. >If you want more precision (meaning a wider range of colors) you can use glColor3ub<

technically glColor3f() should give you infinite color precision. its only limited my the float/double? precision.

10. Originally posted by no-one
>If you want more precision (meaning a wider range of colors) you can use glColor3ub<

technically glColor3f() should give you infinite color precision. its only limited my the float/double? precision.
I was thinking that when i readt it!
I don't think it actually takes the 5th or further behind the
point in account anyhow

11. Yeah, you really SHOULD use floating point numbers in most cases. The reason being that it makes things easier when switching between color depth. If you want to change from 8 bits to 16 bits, it's a lot more difficult when you are using 0 to 255 and now have to change to 0 to 65535. With floating point values from 0 to 1.0, nothing has to be changed.

EDIT: Example -- If you wanted to cycle through the colors and you used math which resulted in numbers 0 through 255 then no matter what color depth you were working in, the colors would end up being limitted to those values. However, if you were using floating point values from 0 to 1.0, the math and values passed can remain the same, but you will get better precision at higher color depths.

12. Wow, i really appreciate all the information.

Yes he gave it to me today, he claimed he didn't want anything, but when i found out (he didn't mention it i overheard it) that he needed a certain program i have i got out my blank cds.

It even still has the CD and backup cd with it. Its a lil over 760 pages long, too tired to check. So far i'm on page 27, i worked today, and it really explains alot. The book goes a little into detail of DirectX, just explaining it and what each part of it is, but is otherwise openGL based. They use GLUT in some example programs from the cd but the course is taught in standard OpenGL. The course does all the graphics via openGL and uses directX for sound and input.

So far it seems very very promising, its consise and up-to-date, and its very well paced. Its worth the \$\$ imo.