[gl2ps] [patch] Enable use without an OpenGL context
David Lonie
david.lonie at kitware.com
Wed Jan 13 15:31:22 CET 2016
On Wed, Jan 13, 2016 at 2:46 AM, Christophe Geuzaine
<cgeuzaine at ulg.ac.be> wrote:
>
> Hi David,
>
> This is a very good idea - I've merged the patch in SVN.
Great!
> Do you think it would be doable to incorporate the parsing of the transform feedback buffers directly in GL2PS?
It would be possible. One of the issues I see is that the new buffers
aren't annotated like the old feedback buffer -- there's no
GL_POINT_TOKEN, etc. The captured attributes (and their ordering) are
dependent on how each feedback transform buffer is configured.
What I've done is keep a list of "roles" around with the feedback
buffer to identify the attributes that are captured, e.g. "Vertex Clip
Coordinates" or "RGBA color". The order of the roles specifies the
order of the attributes in the buffer to make generic parsing
possible. Something similar could be implemented in GL2PS.
For instance, I encapsulate transform feedback buffers in the
vtkTransformFeedback class:
https://gitlab.kitware.com/dlonie/vtk/blob/opengl2-gl2ps/Rendering/OpenGL2/vtkTransformFeedback.h
https://gitlab.kitware.com/dlonie/vtk/blob/opengl2-gl2ps/Rendering/OpenGL2/vtkTransformFeedback.cxx
And parse them here in vtkOpenGLGL2PSHelperImpl::ProcessTransformFeedback:
https://gitlab.kitware.com/dlonie/vtk/blob/opengl2-gl2ps/Rendering/GL2PSOpenGL2/vtkOpenGLGL2PSHelperImpl.cxx#L73
So generic parsing is possible by providing role information or having
a convention in place.
But then, there are some complicated edge cases to worry about. For
example, VTK tends to do coloring in the fragment shader, which cannot
be captured into the transform feedback buffer, and the vert/geo
shaders know nothing about colors. In situations like these, it's
easier to insert the primitives manually since the feedback vertices
can be combined with a separate color array.
So I think it could be done, but it would add a lot of API bloat to
cover all of the possibilities.
Another idea to simplify this would be to add higher level
"gl2psAdd[Point|Line|Triangle]" methods that are more straightforward
to use than gl2psAddPolyPrimitive, but I found the latter easy enough
to use.
Dave