[vtk-developers] Adding GL2PS as a RenderingOpenGL dependency?

David Lonie david.lonie at kitware.com
Thu Mar 21 11:13:18 EDT 2013


Hi all,

I'm trying to implement a feature that will require some ugly changes, and
I'd like to hear some feedback on the approaches I've come up with to solve
it.

First some background about GL2PS:

When GL2PS is used to export an image, it works by parsing the OpenGL
feedback buffer and building up a vector graphics representation of the
rendered primitives. One of the shortcomings of the GL feedback buffer is
that not everything ends up in it, importantly line width and point size
changes.

To solve this, GL2PS uses special passthrough tokens to represent these
state changes, and the developer is required to call gl2psLineWidth or
gl2psPointSize each time glLineWidth/glPointSize are called to ensure that
the change is reflected in the gl2ps output. These functions are quite
simple:

GLint gl2psPointSize(GLfloat value)
{
  if(!gl2ps) return GL2PS_UNINITIALIZED;

  glPassThrough(GL2PS_POINT_SIZE_TOKEN);
  glPassThrough(value);

  return GL2PS_SUCCESS;
}

gl2psLineWidth is very similar.

The problem is: Most of the calls to glPointSize/LineWidth occur in the
RenderingOpenGL module. For GL2PS to function properly, the gl2ps functions
must be called in the same place. I see two ways to solve this:

1) Introduce a dependency on RenderingGL2PS for RenderingOpenGL. I have a
topic branch that does this:

http://review.source.kitware.com/#/c/10364

Marcus has pointed out that the new dependency should be avoided, since the
OpenGL module should be kept as lightweight as possible, and builds that
don't care about GL2PS export shouldn't be forced to compile/use it.

2) The only other way I see to do this is to fake the gl2ps functions, and
insert the glPassThrough calls (with appropriate arguments) everywhere that
glLineWidth etc is called. But this would likely break anything else that
may be monitoring the feedback buffer, and relies on hardcoding the values
for GL2PS symbolic constants into VTK (like GL2PS_POINT_SIZE_TOKEN). This
would no longer work if the GL2PS API changes and the passthrough token
values are reassigned (very unlikely).

Complicating the issue is that the line width values used in the gl2ps call
should be scaled by a value stored in the RenderingGL2PS module...so we'd
need some way to pass this into the OpenGL rendering code if we go with
option 2.

Ideas? Support for either option?

Thanks,
Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20130321/1f60feea/attachment.html>


More information about the vtk-developers mailing list