<div dir="ltr">Hi all,<div><br></div><div style>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.</div><div style>
<br></div><div style>First some background about GL2PS:</div><div><br></div><div style>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.</div>
<div style><br></div><div style>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:</div>
<div style><br></div>GLint gl2psPointSize(GLfloat value)<br>{<br> if(!gl2ps) return GL2PS_UNINITIALIZED;<br><br> glPassThrough(GL2PS_POINT_SIZE_TOKEN);<br> glPassThrough(value);<br><br> return GL2PS_SUCCESS;<br>}<br>
<div>
<br></div><div style>gl2psLineWidth is very similar.</div><div style><br></div><div style>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:</div>
<div style><br></div><div style>1) Introduce a dependency on RenderingGL2PS for RenderingOpenGL. I have a topic branch that does this:</div><div style><br></div><div style><a href="http://review.source.kitware.com/#/c/10364">http://review.source.kitware.com/#/c/10364</a><br>
</div><div style><br></div><div style>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.</div>
<div style><br></div><div style>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).</div>
<div style><br></div><div style>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.</div>
<div style><br></div><div style>Ideas? Support for either option?</div><div style><br></div><div style>Thanks,</div><div style>Dave</div></div>