# Yet another question...

This topic is 4782 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Sorry to keep bothering you guys. One of these days I will get it right. OK so I'm using OpenGL to draw some simple polygons on the screen for practice. Here's what I tried:
       glBegin(GL_QUADS);
glVertex3f(1.0, 1.0, -10.0);
glVertex3f(1.0, 2.0, -10.0);
glVertex3f(2.0, 1.0, -10.0);
glVertex3f(2.0, 2.0, -10.0);
glEnd();

But what shows up is unexpected. It shows a strange looking quadrilateral that has five sides yet I specified four vertices. The first parameter of glVertex3f is the x coordinate in space, the second one being the y coordinate, and the last one being the z coordinate correct? So Then wouldn't this code draw out a square on the screen? Not sure why that shape is showing up. Thanks for any help.

##### Share on other sites
the code you posted looks correct

maybe the problem is elsewhere in your code

##### Share on other sites
I used the code from this topic (the last post):

http://www.gamedev.net/community/forums/topic.asp?topic_id=294988

##### Share on other sites
I think you're not defining vertices in the right order.

A(1,2)   B(2,2)+--------+|        ||        ||        |+--------+D(1,1)   C(2,1)

Here is what you do, you define your quad this way DACB
but you should be defining it ABCD. Try using coordinates as follow:
glBegin(GL_QUADS);  glVertex3f(1.0, 2.0, -10.0);  glVertex3f(2.0, 2.0, -10.0);  glVertex3f(2.0, 1.0, -10.0);  glVertex3f(1.0, 1.0, -10.0);glEnd();

hope that helps !
Matt

##### Share on other sites
I think you're drawing your verticies in the incorrect order. It should go in a CW or CCW circle like so:

glVertex3f(1.0, 1.0, -10.0);
glVertex3f(1.0, 2.0, -10.0);
glVertex3f(2.0, 2.0, -10.0);
glVertex3f(2.0, 1.0, -10.0);
glEnd();