View Full Version : SGI GLU Sample Implementation fixes

John Shell
03-20-2006, 10:52 AM
I hope this is the appropriate forum for this. I have been working
with and debugging the NURBS portion of SGI's sample implementation
of GLU and propose the following changes/fixes.

- The following is a bug fix. The original code only works if the
stride is 2, which is not the case for homogenous coordinates.
libnurbs/internals/arctess.cc, Line 338:
for(i=1, j=2; i<bezierArc->order; i++, j+= bezierArc->stride)
Change to:
for(i=1, j=bezierArc->stride; i<bezierArc->order; i++, j+= bezierArc->stride)

- The function monoTriangulationFun calls
monoTriangulationRecFun with zeroes for both of the current
indices to the inc_chain and dec_chain vertex arrays. If both of
these containers are empty (which can happen--did for me with one
surface), monoTriangulationRecFun will assert. I don't know
if this indicates a flaw in the data, but to avoid the assertion, I
added the following:
libnurbs/nurbtess/monoTriangulation.cc, Insert at line 622
(before call to monoTriangulationRecFun):
if (!(0 == inc_chain.getNumElements() && 0 == dec_chain.getNumElements()))

- Initialization of the member variable output_triangles of
the class [/I]OpenGLCurveEvaluator[/I] was overlooked. NURBS curves
won't render in a debug build because of this. Add the following
initialization in the constructor:
libnurbs/interface/glcurveval.cc, Insert at line 77:
output_triangles = 0; //don't output triangles by default

- The following change eliminates a compiler warning (using MS VC6).
Add the following delete operator to class PooledObj:
libnurbs/internals/bufpool.h, Insert at line 131:
inline void operator delete( void *, Pool & ) { assert( 0 ); }

Another problem this library has, which I have not yet debugged (and
may not get to), is that it does not render trimmed surfaces
correctly when using GLU_PARAMETRIC_ERROR for the sampling method.
The edges of the trim lines are rendered with far too few segments
(at least with NURBS trim curves--not sure about piecewise trim
curves). If anyone has a fix for this, please post it.

I hope this helps helps other people working with GLU NURBS and that
SGI sees this and incorporates these changes into its sample

(I will be posting a copy of this to the comp.graphics.api.opengl
newsgroup also.)

John Shell