Joel
Joel

Reputation: 1630

Draw shapes given list of lines

I am working with C# OpenTK, but any code in C++ OpenGL is fine, i understand it.

I have a list of Markers. A Marker is defined as a 2 coordinate, and a pointer to the next marker in the loop. Essentially, if you were to follow the path of those pointers, you would eventually reach the Marker you started with. This is how shapes are initially defined.

One of those 'loops' may not be all the markers in the list. Multiple 'loops' may be contained. Take the letter 'A' for example:

enter image description here

This shape here would be defined by 2 'loops'. One is the outline (8 Markers), while the other loop would be the triangle within (3 Markers).

(Marker - Pointer)

I need a method that will allow me to draw something like this to the screen. The solutions stated here would correctly solve the issue on a bitmap level (going through pixel after pixel to check if it within the polygon), however would be quite inefficient, especially given the fact that these markers shall be moved continuously at run time.

It is required that these shapes should be able to include things such as the triangle in an A (inverting), and preferably would allow for overlapping boundaries of the 'loops', but this second thing is not a necessity.

I'm guessing the direction taken will either be some sort of conversion to triangles, or some fancy trick with built in OpenGL features.

Upvotes: 0

Views: 500

Answers (1)

genpfault
genpfault

Reputation: 52084

You're looking for triangulation with holes.

Check out the General Polygon Clipper (GPC).

Upvotes: 1

Related Questions