AC: Triangulate quads and polygons #1302
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm a bit unclear whether there's any interest in accepting fixes, especially for use of newer GL features, and what branch it makes sense to apply them to, so I've just left this one on OpenSceneGraph-3.6.5 for now. It stems from me playing around with instanced geometry shaders for single-pass multiviewport rendering in osgXR / FlightGear (where work is ongoing to switch to GL core profile), since mesa on my AMD GPU doesn't support the OVR_multiview2 extension.
The AC plugin creates geometry containing quads and polygons, neither of which can be handled with geometry shaders, resulting in GL_INVALID_OPERATION errors from glDrawElements when geometry shaders are in use.
This is fixed by generating a single DrawElements of triangles from both _triangles and _quads (triangulating the quads as if each is a triangle fan), and treating convex polygons (in _polygons) as triangle fans.
Concave polygons (in _toTessellatePolygons) are already converted into triangle modes by a Tessellator object.