PDA

View Full Version : GL_QUADS draws triangle?



polymath
06-22-2010, 11:40 AM
Hi, i'm following NeHe's tutorials (loosely) and for some reason, the following code is drawing a 45-45-90 triangle instead of a quadrilateral (with the right angle in the upper-right hand corner). Any help is greatly appreciated.

My paint function:


glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

glTranslatef(-1.5f,0.0f,-6.0f);

glBegin(GL_TRIANGLES);
glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
glVertex3f(0.0f, 1.0f, 0.0f);
glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
glVertex3f(1.0f,-1.0f, 0.0f);
glEnd();

glTranslatef(3.0f,0.0f,0.0f);

glBegin(GL_QUADS);
glColor4f(0.5f, 0.5f, 1.0f, 1.0f);
glVertex3f(-1.0f, 1.0f, 0.0f);
glVertex3f(1.0f, 1.0f, 0.0f);
glVertex3f(1.0f,-1.0f, 0.0f);
glVertex3f(1.0f,-1.0f, 0.0f);
glEnd();

Bruce Wheaton
06-22-2010, 12:20 PM
Because the last two vertices you send are exactly the same?

Was it quicker to make this post than read the code once?

Bruce

codebreaker
06-22-2010, 12:21 PM
Heh - cut and paste error. last two points of your quad are the same point.

polymath
06-23-2010, 09:31 AM
Sorry. I read the code like 50 times and sometimes even though i've read it so much i can't catch a simple error- cause *I* know what i mean, so my brain adds in a negative sign that isn't there. Thought i was doing a good thing by not copying/pasting code from the tutorial and typing it all myself so i could remember all the functions :P

Thank you.