madcat
madcat

Reputation: 49

polygon tessellation in opengl shader

I want 20k+ 2D polygons to be rendered in opengl with outline & fill.

Some polygons are concave.

Is it possible to do this using shaders?

Upvotes: 2

Views: 2894

Answers (1)

Andreas Brinck
Andreas Brinck

Reputation: 52519

You don't need shaders for this:

glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); //Fill
glDrawElements(...);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); //Outline
glDrawElements(...);

If the polygons are concave you'll have to tesselate them, either manually or using the gl utility library, glu. Look at gluNewTess. If you decide to tesselate the polygons yourself you'll have to remember to set the correct edge flags so that the interior edges of the tesselation aren't rendered, see glEdgeFlagPointer.

EDIT: I found the following link on how to use the stencil buffer to render concave polygons.

Upvotes: 2

Related Questions