• Advertisement
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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 this post


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

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

Share this post


Link to post
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 this post


Link to post
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:

glBegin(GL_QUADS);
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();

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement