Package gov.nasa.worldwind.util
Class GLUTessellatorSupport
- java.lang.Object
-
- gov.nasa.worldwind.util.GLUTessellatorSupport
-
public class GLUTessellatorSupport extends java.lang.Object
GLUTessellatorSupport is a utility class for configuring and using aGLUtessellator
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
Nested Classes Modifier and Type Class Description static class
GLUTessellatorSupport.CollectIndexListsCallback
Provides the callback class used to capture the shapes determined by the tessellator.static class
GLUTessellatorSupport.CollectPrimitivesCallback
Provides the callback class used to capture triangle and line primitive indices determined by the tessellator.protected static class
GLUTessellatorSupport.OGLDrawPrimitivesCallback
static class
GLUTessellatorSupport.RecursiveCallback
Recursively forwards boundary tessellation results from one GLU tessellator to another.static class
GLUTessellatorSupport.VertexData
Provides a container for associating a tessellator's vertex with its index and application-specified edge flag.
-
Field Summary
Fields Modifier and Type Field Description protected com.jogamp.opengl.glu.GLUtessellator
tess
-
Constructor Summary
Constructors Constructor Description GLUTessellatorSupport()
Creates a new GLUTessellatorSupport, but otherwise does nothing.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
beginTessellation(com.jogamp.opengl.glu.GLUtessellatorCallback callback, Vec4 normal)
Prepares this GLUTessellatorSupport's internal GLU tessellator for use.static java.lang.String
convertGLUTessErrorToString(int errno)
Converts the specified GLU tessellator error number to a string description.static com.jogamp.opengl.glu.GLUtessellatorCallback
createOGLDrawPrimitivesCallback(com.jogamp.opengl.GL2 gl)
Creates a newGLUtessellatorCallback
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.com.jogamp.opengl.glu.GLUtessellator
getGLUtessellator()
Returns this GLUTessellatorSupport's internalGLUtessellator
instance.
-
-
-
Method Detail
-
getGLUtessellator
public com.jogamp.opengl.glu.GLUtessellator getGLUtessellator()
Returns this GLUTessellatorSupport's internalGLUtessellator
instance. This returns a valid GLUtessellator instance if called betweenbeginTessellation(com.jogamp.opengl.glu.GLUtessellatorCallback, gov.nasa.worldwind.geom.Vec4)
andendTessellation()
. 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.
-
beginTessellation
public void beginTessellation(com.jogamp.opengl.glu.GLUtessellatorCallback callback, Vec4 normal)
Prepares this GLUTessellatorSupport's internal GLU tessellator for use. This initializes the internal GLUtessellator to a new instance by invokingGLU.gluNewTess()
, and configures the tessellator with the specified callback and normal with calls toGLU.gluTessCallback(com.jogamp.opengl.glu.GLUtessellator, int, com.jogamp.opengl.glu.GLUtessellatorCallback)
andGLU.gluTessNormal(com.jogamp.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:
java.lang.IllegalArgumentException
- if the callback or the normal is null.
-
endTessellation
public void endTessellation()
Frees any GLU resources used by this GLUTessellatorSupport, and invalidates this instance's internal GLU tessellator.
-
createOGLDrawPrimitivesCallback
public static com.jogamp.opengl.glu.GLUtessellatorCallback createOGLDrawPrimitivesCallback(com.jogamp.opengl.GL2 gl)
Creates a newGLUtessellatorCallback
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:
java.lang.IllegalArgumentException
- if the GL is null.
-
convertGLUTessErrorToString
public static java.lang.String convertGLUTessErrorToString(int errno)
Converts the specified GLU tessellator error number to a string description. This returns "unknown" if the error number is not recognized.- Parameters:
errno
- a GLU enumeration indicating the error.- Returns:
- a string description of the error number.
-
-