PDA

View Full Version : Drawing on top of textured polygon



flightdeck
08-24-2005, 08:07 AM
Hello all,

I am writing a simulated gauge program. I have a textured polygon for the face of the gauge and I am trying to draw the neegle pointer on top of this textured polygon, but it won't show up. Here is a code snipit.

glLoadIdentity();
glTranslatef(0.0f, 0.0f, -3.0f);
glColor3f(1.0,1.0,1.0);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2f(-1.0f, -1.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex2f( 1.0f, -1.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex2f( 1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex2f(-1.0f, 1.0f);
glEnd();

/////////THIS PART WON"T SHOW UP????????????
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -3.0f);
glColor3f(1,1,1);
glBegin(GL_QUADS);
glVertex2f(-.20,.20);
glVertex2f(.20,-.20);
glVertex2f(-.20,-.20);
glEnd();

Any Help is greatly appreciated. i don't want to have to texture the needle to have it show up, that seems unecessary.

Jason

Aeluned
08-24-2005, 08:26 AM
A quad is defined by 4 vertices; you're only sending 3 :p

perhaps you meant glBegin(GL_TRIANGLES).

jide
08-24-2005, 09:11 AM
But what Aeluned said, your two figures have the same z value (-3) and are coplanar. So, you will face z-fighting.

flightdeck
08-24-2005, 09:38 AM
Ok, fixed those errors. The shape now shows up, but it is black, even though I assign white as the color for that quad.

Thanks,

Jason

flightdeck
08-24-2005, 09:53 AM
Ok, figured it out! enable and disable texturing.

Thanks all.

Jason