PDA

View Full Version : polygon drawing for a noob



jfleong
11-06-2008, 08:49 PM
Hey all,
I just started learning openGL for an application that I am working on. My task is to draw a polygon that can be:
1. outlined
2. filled
3. texture filled
The outlined polygon is simple with the primType GL_LINE_STRIP. When i try to draw things of the GL_POLYGON primType my object does not render correctly at all. Any suggestions to why this is happenening?

Thanks,
jfleong

Zengar
11-07-2008, 12:52 AM
You can only render convex polygons with GL_POLYGON.

IneQuation.pl
11-07-2008, 07:38 AM
I'd recommend using GL_TRIANGLES or, even better, GL_TRIANGLE_STRIP. The latter requires a special geometry layout called a triangle strip, though (see this wikipedia article (http://en.wikipedia.org/wiki/Triangle_strip)), and not all polygons can be made into such strips.

Mike Werner
11-14-2008, 01:01 AM
The code at the link below does what you are trying to do. Maybe by looking at this code you'll be able to figure out what you did wrong? Good luck.

Triangle Demo Source Code (http://pastebin.com/me6a6854)

_NK47
11-14-2008, 02:36 AM
anything other then triangles are not optimized well on hardware, that is anything else has to be split up into subtriangles. even lines are rendered with two triangles on some cards. i would forget about GL_POLYGON and use TRIANGLES only and you can render convex and concave geometry.