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 4 of 4

Thread: Wrong Color for 2D quad

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    5

    Wrong Color for 2D quad

    Hi There,

    I am trying to show a colored quad on the 2D screen with the following code:

    glColor3f(1.0f, 1.0f, 1.0f);

    glBegin(GL_QUADS);
    glVertex2f(300, 500); // vertex 1
    glVertex2f(300, 300); // vertex 2
    glVertex2f(600, 300); // vertex 3
    glVertex2f(600, 500); // vertex 4
    glEnd();

    glColor3f(1.0f, 1.0f, 1.0f); // If I don't put this, the whole screen become the previous color

    Normally I would expect it to be full white, but I get an 50% gray. Is something with the blend function? Any clues what might be the problem?

    Thanks

  2. #2
    Intern Contributor
    Join Date
    Oct 2008
    Posts
    86

    Re: Wrong Color for 2D quad

    Try adding this line before glColor3f:
    Code :
    glDisable(GL_LIGHTING);

    But of course, check all of these:
    Lighting, materials, normals, shading, textures, depth testing, blending, matrix transformations, etc...

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    5

    Re: Wrong Color for 2D quad

    I tried disabling the lighting but it doesn't solve the problem.

    I am getting some clues. Check these 2 images:

    http://www.imagitiel.com/test/quad1.jpg
    http://www.imagitiel.com/test/quad2.jpg

    I am drawing the 2D shapes over my 3D scene, I want to eventually make a 2D HUD. So this is giving me the impression that the white of my quad is getting blended with the very last pixel drawn from the 3D scene. If I don't show the floor, the quad become light blue like the sky dome. If I show the floor, it then becomes gray. The fire image I am displaying however is displaying fine. But this happen if I use the instruction glColor3f(1.0f, 1.0f, 1.0f);.

    Any clues?

  4. #4
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    5

    Re: Wrong Color for 2D quad

    Okay guys,

    I somehow fixed the problem with

    glBindTexture(GL_TEXTURE_2D, 0);

    Just before drawing my shapes.

Posting Permissions

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