PDA

View Full Version : glColor Issue



BlackICE
09-12-2011, 08:30 AM
Hi,

I am having an issue with glColor seemingly inheriting the last colour.

A summary of my draw loop code looks like this:



GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

GL11.glLoadIdentity();

GL11.glPushMatrix();

GL11.glBindTexture(target, textureID);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);

GL11.glBegin(GL11.GL_QUADS);

GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex3f(-5.0f, 5.0f, 5.0f);
GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex3f(5.0f, 5.0f, 5.0f);
GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex3f(5.0f, 5.0f, -5.0f);
GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex3f(-5.0f, 5.0f, -5.0f);

GL11.glEnd();

//Draw white triangle

GL11.glBegin(GL11.GL_TRIANGLES);

GL11.glColor3f(1.0f, 1.0f, 1.0f);
GL11.glVertex3f(5.0f, 10.0f, 40.0f);

GL11.glColor3f(1.0f, 1.0f, 1.0f);
GL11.glVertex3f(5.0f, 0.0f, 40.0f);

GL11.glColor3f(1.0f, 1.0f, 1.0f);
GL11.glVertex3f(-5.0f, 0.0f, 40.0f);

GL11.glEnd();

GL11.glPopMatrix();


The problem is the triangle appears to be picking up a colour from the texture I am using. So it doesn't come out white, in my case it comes out green!

If I change the texture I am using the colour of the triangle changes to match.

What am I missing?

ZbuffeR
09-12-2011, 08:34 AM
When you don't want texturing, you have to disable it.

BlackICE
09-12-2011, 08:59 AM
Thanks ZbuffeR, adding glEnable(GL_TEXTURE_2D); and glDisable(GL_TEXTURE_2D); fixed the problem!