Open lordmauve opened 5 years ago
I think GL_LINE_ADJACENCY
might be the way to do this.
A polygon of n vertices should allocate n + 1 vertices and assign vertex 0 a position (nan, nan)
, that also has the fill colour.
Then we can indicate to the geometry shader whether to draw strokes or fills. GL_LINE_ADJACENCY
basically means we can send 4 vertices into each geometry shader invocation.
verts[0]
is the sentinel vertex, then verts[1:]
indicate a triangle, and the fill colour comes from verts[0]verts
are the line adjacency needed for stroking with mitres, their colours are the stroke colours
Currently shapes may be either filled or not.
This was because the generic
VAO
class only maintains one buffer of indirect commands and makes only one draw call.A filled, stroked shape can share vertices; only the draw mode and index sequence will differ. So these could be held in a single VAO.
We could subclass VAO to allow separate index allocations for stroke and fill commands. These could share the index buffer and simply exist as separate indirect draw commands.
Maybe the way to achieve this is to split out a separate manager for indirect draw commands currently integrated with the VAO code here to allow multiple per VAO.
Additionally shapes should be able to toggle filling and stroke visibility after creation, probably by zeroing and resetting the number of indices to draw within the draw command (a draw command of 0 vertices should be a no-op). The ability to set this would also allow line trails that grow without needing to be reallocated.