PDA

View Full Version : Wrong Color for 2D quad



Krimsom King
04-05-2012, 07:30 PM
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

sammie381
04-05-2012, 08:38 PM
Try adding this line before glColor3f:


glDisable(GL_LIGHTING);


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

Krimsom King
04-06-2012, 07:51 AM
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?

Krimsom King
04-06-2012, 10:07 AM
Okay guys,

I somehow fixed the problem with

glBindTexture(GL_TEXTURE_2D, 0);

Just before drawing my shapes.