OpenGL issue

Hey, My problem is simple, openGL is skipping a point
here's the code for the polygon:
1
2
3
4
5
6
7
8
glBegin( GL_POLYGON );
        glVertex3f( 0, -30, 0);
        glVertex3f( -5 ,-10, 0); // point 2
        glVertex3f( 30, 0, 0 );
        glVertex3f( 0 , 30, 0);
        glVertex3f( -30, 0, 0);
		//glVertex3f( 0,  15, 0);
    glEnd();

For some reason, It's not showing point 2. If someone could tell me presisely where and why I'm being a 'tard it would be very appreciated.
GL_POLYGON only makes a convex polygon.

That point makes it concave, so it doesn't work
Crap, How can I make a (anything) Polygon?
It's actually really involved, unfortuantely. You'll have to break concave polygons down until you have a series of convex polygons.

Here's an article to get you started: http://en.wikipedia.org/wiki/Polygon_triangulation

It might be worth it to look for a library that does this. I don't know of any so I can't recommend one, but there must be some out there, as this is a very common requirement.
I'm currently learning opengl with the book "Beginning OpenGL Game Programming" and it said that usually game developers prefer to draw triangles than polygons to avoid problems like that one. Though I'm still in chapter 3 and I don't know much yet.

Good luck!

[edit]
Oh crap! I should have check Disch's link first, well maybe that's it. Triangle is the solution.
Last edited on
Thanks, and that's gonna be a problem :( oh well. Thanks for pointing me in the right direction.
Topic archived. No new replies allowed.