GL_POLYGON trouble
I'm trying to remake SFCave (http://hp.vector.co.jp/authors/VA003665/...ave-e.html ) in OpenGL.
I've got everything down pretty good. When I draw the cave using GL_LINE_LOOP, everything is fine. However, when I draw the cave using GL_POLYGON, there are minor discrepancies in the outcome. Some parts of the cave seem to be left out when drawn, resulting in an ugly look. The top of the cave is supposed to look like it fits perfectly into the bottom of the cave. When I draw using GL_LINE_LOOP, that is the case, everything is perfect. But when I draw using GL_POLYGON (this is what I want to do for the final product), the top of the cave does not "match" (lock and key type of thing) the bottom. Any ideas why? Thanks.
I've got everything down pretty good. When I draw the cave using GL_LINE_LOOP, everything is fine. However, when I draw the cave using GL_POLYGON, there are minor discrepancies in the outcome. Some parts of the cave seem to be left out when drawn, resulting in an ugly look. The top of the cave is supposed to look like it fits perfectly into the bottom of the cave. When I draw using GL_LINE_LOOP, that is the case, everything is perfect. But when I draw using GL_POLYGON (this is what I want to do for the final product), the top of the cave does not "match" (lock and key type of thing) the bottom. Any ideas why? Thanks.
Oh, you stepped into the dark corner of graphics.
In short, anything you draw with GL_POLYGON must be convex. So, if your polygon is concave, then you have to break it up into smaller convex sections. (Which means that you're going to break it into triangles at some point.) Google for tesselation, or get in the ring with gluTesselator. (Chapter 11 in the Red Book.)
Good luck, I tell you.
In short, anything you draw with GL_POLYGON must be convex. So, if your polygon is concave, then you have to break it up into smaller convex sections. (Which means that you're going to break it into triangles at some point.) Google for tesselation, or get in the ring with gluTesselator. (Chapter 11 in the Red Book.)Good luck, I tell you.
Fenris is right. But if you are creating the tunnel from that java game (fun!) it should be pretty obvious where to break it up into triangles - or into a triangle strip.
And maybe check out the post "Collision Detection (Point-Polygon)" for algorithms to collide a point with a triangle to handle your collisions.
good luck.
And maybe check out the post "Collision Detection (Point-Polygon)" for algorithms to collide a point with a triangle to handle your collisions.
good luck.
im not quite sure its a problem with concave/convex polygons. it appears to happen randomly, although i may be mistaken.
here is a screenshot (note: this image will only be up for a short amount of time)
![[Image: idevgames_post.jpg]](http://129.44.120.175:81/idevgames_post.jpg)
the red lines are drawn using GL_LINE_LOOP, whereas the dark gray is drawn with GL_POLYGON (obviously).
here is a screenshot (note: this image will only be up for a short amount of time)
![[Image: idevgames_post.jpg]](http://129.44.120.175:81/idevgames_post.jpg)
the red lines are drawn using GL_LINE_LOOP, whereas the dark gray is drawn with GL_POLYGON (obviously).
Well, the dark gray is not a convex polygon, so the results are undefined. I think you'll have to split it up.
Alright, i guess ill have to do it that way. Thanks.
*sigh* more work for me =P
*sigh* more work for me =P
Just wanted to let you know that i solved the problem using quad-strips. Everything looks beautiful now. Expect a release very soon.
Thanks.
Thanks.

