PDA

View Full Version : What's wrong with this?



EvilGenius
05-04-2001, 07:37 PM
Peace folks
I tried to draw a simple polygon using these coordinates:
glBegin(GL_POLYGON);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(0.0f, -2.0f, 0.0f);
glVertex3f(0.5f, -1.2f, 0.0f);
glVertex3f(1.0f, -2.0f, 0.0f);
glVertex3f(1.0f, 0.0f, 0.0f);
glVertex3f(0.5f, -0.1f, 0.0f);
glEnd();
It is supposed to look like a X where the sides are flat. However, the code draws the top also flat. It connects the two upper vertices directly although it is not supposed to do that. What am I doing wrong and how do I fix it?

Warrior
05-04-2001, 07:48 PM
hehe
dude the shape those coordinates are making in my mind look nothing like an X
more like a mess
hehe
your not doing anything wrong i can see, just shift the vertices so you can get a reconizeable shape, then refine them to make the shape your desire.

EvilGenius
05-04-2001, 08:03 PM
Well, let me try to clarify the mess a little bit http://www.opengl.org/discussion_boards/ubb/smile.gif
It is supposed to look like a rectangle whose top and bottom are concave. Hope this helps.

DFrey
05-04-2001, 08:07 PM
The problem is that the shape you are trying to draw is concave, and GL_POLYGON can only be a convex polygon. You'll have to split it down the middle into two convex polygons.

[This message has been edited by DFrey (edited 05-04-2001).]

EvilGenius
05-05-2001, 05:20 PM
Many thanks for the hint DFrey.