NASA World Wind

gov.nasa.worldwind.util
Class GLUTessellatorSupport

java.lang.Object
  extended by gov.nasa.worldwind.util.GLUTessellatorSupport

public class GLUTessellatorSupport
extends Object

GLUTessellatorSupport is a utility class for configuring and using a GLUtessellator to tessellate complex polygons into triangles.

The standard pattern for using GLUTessellatorSupport to prepare a GLUtessellator is as follows: GLUTessellatorSupport glts = new GLUTessellatorSupport();
GLUtessellatorCallback cb = ...; // Reference to an implementation of GLUtessellatorCallback.
Vec4 normal = new Vec4(0, 0, 1); // The polygon's normal. This example shows an appropriate normal for tessellating x-y coordinates.


glts.beginTessellation(cb, new Vec4(0, 0, 1));
try
{
GLUtessellator tess = glts.getGLUtessellator();
}
finally
{
glts.endTessellation();
}


Nested Class Summary
static class GLUTessellatorSupport.CollectIndexListsCallback
          Provides the callback class used to capture the shapes determined by the tessellator.
protected static class GLUTessellatorSupport.OGLDrawPrimitivesCallback
           
 
Field Summary
protected  GLUtessellator tess
           
 
Constructor Summary
GLUTessellatorSupport()
          Creates a new GLUTessellatorSupport, but otherwise does nothing.
 
Method Summary
 void beginTessellation(GLUtessellatorCallback callback, Vec4 normal)
          Prepares this GLUTessellatorSupport's internal GLU tessellator for use.
static GLUtessellatorCallback createOGLDrawPrimitivesCallback(GL2 gl)
          Creates a new GLUtessellatorCallback that draws tessellated polygons as OpenGL primitives by calling glBegin, glEnd, and glVertex.
 void endTessellation()
          Frees any GLU resources used by this GLUTessellatorSupport, and invalidates this instance's internal GLU tessellator.
 GLUtessellator getGLUtessellator()
          Returns this GLUTessellatorSupport's internal GLUtessellator instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tess

protected GLUtessellator tess
Constructor Detail

GLUTessellatorSupport

public GLUTessellatorSupport()
Creates a new GLUTessellatorSupport, but otherwise does nothing.

Method Detail

beginTessellation

public void beginTessellation(GLUtessellatorCallback callback,
                              Vec4 normal)
Prepares this GLUTessellatorSupport's internal GLU tessellator for use. This initializes the internal GLUtessellator to a new instance by invoking GLU.gluNewTess(), and configures the tessellator with the specified callback and normal with calls to GLU.gluTessCallback(javax.media.opengl.glu.GLUtessellator, int, javax.media.opengl.glu.GLUtessellatorCallback) and GLU.gluTessNormal(javax.media.opengl.glu.GLUtessellator, double, double, double), respectively.

Parameters:
callback - the callback to configure the GLU tessellator with.
normal - the normal to configure the GLU tessellator with.
Throws:
IllegalArgumentException - if the callback or the normal is null.

createOGLDrawPrimitivesCallback

public static GLUtessellatorCallback createOGLDrawPrimitivesCallback(GL2 gl)
Creates a new GLUtessellatorCallback that draws tessellated polygons as OpenGL primitives by calling glBegin, glEnd, and glVertex.

Parameters:
gl - the GL context to draw into.
Returns:
a new GLUtessellatorCallback for drawing tessellated polygons as OpenGL primtives.
Throws:
IllegalArgumentException - if the GL is null.

endTessellation

public void endTessellation()
Frees any GLU resources used by this GLUTessellatorSupport, and invalidates this instance's internal GLU tessellator.


getGLUtessellator

public GLUtessellator getGLUtessellator()
Returns this GLUTessellatorSupport's internal GLUtessellator instance. This returns a valid GLUtessellator instance if called between beginTessellation(javax.media.opengl.glu.GLUtessellatorCallback, gov.nasa.worldwind.geom.Vec4) and endTessellation(). This returns null if called from outside a beginTessellation/endTessellation block.

Returns:
the internal GLUtessellator instance, or null if called from outside a beginTessellation/endTessellation block.

NASA World Wind