Primaries: OpenGL

This is a discussion on Primaries: OpenGL within the Game Programming forums, part of the General Programming Boards category; Ok, there is a line i am worried about in this small exerpt of a opengl tutorial i am reading. ...

  1. #1
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331

    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. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    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. #3
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    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.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  4. #4
    napKINfolk.com napkin111's Avatar
    Join Date
    Apr 2002
    Posts
    310
    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
    "The best way to get answers is to just keep working the problem, recognizing when you are stalled, and directing the search pattern.....Don’t just wait for The Right Thing to strike you – try everything you think might even be in the right direction, so you can collect clues about the nature of the problem."
    -John Carmack

  5. #5
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    Originally posted by napkin111
    Actually the primary colors are red, yellow, and blue...
    Not in light. Light it's Red, Green and Blue.

  6. #6
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    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. #7
    Shadow12345
    Guest
    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. #8
    napKINfolk.com napkin111's Avatar
    Join Date
    Apr 2002
    Posts
    310
    ACK! He's giving you that book?? I'll buy it from you... Why would anyone want to do apps programming??

    //napKIN
    "The best way to get answers is to just keep working the problem, recognizing when you are stalled, and directing the search pattern.....Don’t just wait for The Right Thing to strike you – try everything you think might even be in the right direction, so you can collect clues about the nature of the problem."
    -John Carmack

  9. #9
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    >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.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  10. #10
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    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. #11
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    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.
    Last edited by Polymorphic OOP; 01-08-2003 at 03:55 PM.

  12. #12
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 11:17 AM
  2. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 01:34 PM
  3. OpenGL .dll vs video card dll
    By Silvercord in forum Game Programming
    Replies: 14
    Last Post: 02-12-2003, 07:57 PM
  4. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 11:14 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21