• 0

openGL Problem


Question

I'm having a weird problem with this star I'm drawing. When it is drawn with GL_LINE_LOOP is shows all the proper lines. But when its is drawn using GL_POLYGON it is messed up. (See Pictures Below) I have pasted in my code being used to draw it. Any help would be amazing.

Thanks.

glBegin(GL_LINE_LOOP);

glColor3ub(255,255,255);

glVertex2f(0.12,0); //bottom left

glVertex2f(0.25,0.12);

glVertex2f(0.38,0); //bottom right

glVertex2f(0.32,0.19);

glVertex2f(0.45,0.3); //middle right

glVertex2f(0.3,0.3);

glVertex2f(0.25,0.5); //top

glVertex2f(0.2,0.3);

glVertex2f(0.05,0.3); //middle left

glVertex2f(0.17,0.20);

glVertex2f(0.12,0);

glEnd();

post-17944-1128910931.gif

post-17944-1128910940.gif

Link to comment
https://www.neowin.net/forum/topic/383127-opengl-problem/
Share on other sites

5 answers to this question

Recommended Posts

  • 0

GL_POLYGON is only good for drawing convex polygons. a star is concave :)

what happens is it connects the first vertex to ALL the other vertices... so it turns out you have extra polygons :p

you should start at the middle of the star and make the "rays"

Link to comment
https://www.neowin.net/forum/topic/383127-opengl-problem/#findComment-586649625
Share on other sites

  • 0
  mstrmind said:
Thank you very much for the help.  I should have my star under control by later today.

Any idea why GL_POLYGON was set up for convex shapes?  Seems kinda silly to only support one type of polygon

586651429[/snapback]

Well, concave polygons are very slow to fill because you must find all places to fill in between whereas with a convex polygon it's very fast. GLU however provides routines to tessellate concave polygons into convex ones.

Link to comment
https://www.neowin.net/forum/topic/383127-opengl-problem/#findComment-586651798
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.