Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: OGL ignores glColor4f

  1. #1
    Junior Member Newbie
    Join Date
    May 2002
    Posts
    2

    OGL ignores glColor4f

    Hello,

    I tried to put the line :

    glColor4f(1.0,0.0,0.0,0.9);

    just after:

    glBegin(GL_QUADS);

    But still the quades are white.. WHY????
    Should I glEnable something?

    I would be happy to get any ideas

    Cheers,
    Libby

  2. #2
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    4,388

    Re: OGL ignores glColor4f

    Do you have texturing enabled?

    Bad texture is rendered white.

    Do you have lighting enabled, this may be undermining your efforts.

  3. #3
    Junior Member Newbie
    Join Date
    May 2002
    Posts
    2

    Re: OGL ignores glColor4f

    Thanks a lot,
    But......
    Now I comment out the line:

    glEnable(GL_LIGHTING);

    And it does display the colors, but it doesn't display any light.

    How can I have color AND light?

    Libby

  4. #4
    Junior Member Newbie
    Join Date
    Apr 2002
    Posts
    28

    Re: OGL ignores glColor4f

    Hi Libby,
    Enable GL_COLOR_MATERIAL, this uses your calls of glColor to set the material properties. Otherwise you will need to set up materials using glMaterial. For example:

    glEnable(GL_LIGHTING);
    glEnable(GL_COLOR_MATERIAL);
    glColorMaterial(GL_FRONT, GL_DIFFUSE);
    glColor4f(1, 0, 0, 1);

    is the same as:

    float diff[] = {1, 0, 0, 1};
    glEnable(GL_LIGHTING);
    glMaterialfv(GL_FRONT, GL_DIFFUSE, diff);

    jimmi

  5. #5
    Member Regular Contributor
    Join Date
    Jan 2002
    Location
    Kingston, Jamaica, W.I.
    Posts
    268

    Re: OGL ignores glColor4f

    Once you enable lighting you have two options to ensure your colour shows properly.

    1) Use glMaterial*() to specify colours.
    2) Use glEnable(GL_COLOR_MATERIAL) and glColorMaterial*(). Then your glColor*() calls will work.

  6. #6
    Junior Member Newbie
    Join Date
    May 2002
    Posts
    2

    Re: OGL ignores glColor4f

    Thanks Jimmie, You're a genious! You made my day, now I can go home!

  7. #7
    Junior Member Newbie
    Join Date
    May 2002
    Posts
    2

    Re: OGL ignores glColor4f

    And thanks also to Furrage!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •