//----------------------------------------------------------------------
// Projection routines
//
/** Interface to C language function:
GLint gluProject(GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble * model, const GLdouble * proj, const GLint * view, GLdouble * winX, GLdouble * winY, GLdouble * winZ);
*/
public boolean gluProject(double objX, double objY, double objZ, double[] model, double[] proj, int[] view, double[] winX, double[] winY, double[] winZ);
/**
* Convenience routine for gluProject that accepts the outgoing window
* coordinates as a single array.
*/
public boolean gluProject(double objx,
double objy,
double objz,
double[] modelMatrix,
double[] projMatrix,
int[] viewport,
double[] winPos);
/** Interface to C language function:
GLint gluUnProject(GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble * model, const GLdouble * proj, const GLint * view, GLdouble * objX, GLdouble * objY, GLdouble * objZ);
*/
public boolean gluUnProject(double winX, double winY, double winZ, double[] model, double[] proj, int[] view, double[] objX, double[] objY, double[] objZ);
/**
* Convenience routine for gluUnProject that accepts the outgoing
* object coordinates (a 3-vector) as a single array.
*/
public boolean gluUnProject(double winX, double winY, double winZ, double[] model, double[] proj, int[] view, double[] objPos);
/** Interface to C language function:
GLint gluUnProject4(GLdouble winX, GLdouble winY, GLdouble winZ, GLdouble clipW, const GLdouble * model, const GLdouble * proj, const GLint * view, GLdouble nearVal, GLdouble farVal, GLdouble * objX, GLdouble * objY, GLdouble * objZ, GLdouble * objW);
*/
public boolean gluUnProject4(double winX, double winY, double winZ, double clipW, double[] model, double[] proj, int[] view, double nearVal, double farVal, double[] objX, double[] objY, double[] objZ, double[] objW);
/**
* Convenience routine for gluUnProject4 that accepts the outgoing
* object coordinates (a 4-vector) as a single array.
*/
public boolean gluUnProject4(double winX, double winY, double winZ, double clipW, double[] model, double[] proj, int[] view, double nearVal, double farVal, double[] objPos);
//----------------------------------------------------------------------
// Tesselation routines
//
/*****************************************************************************
* gluBeginPolygon and {@link net.java.games.jogl.GLU#gluEndPolygon
* gluEndPolygon} delimit the definition of a nonconvex polygon. To define
* such a polygon, first call gluBeginPolygon. Then define the contours
* of the polygon by calling {@link net.java.games.jogl.GLU#gluTessVertex
* gluTessVertex} for each vertex and
* {@link net.java.games.jogl.GLU#gluNextContour gluNextContour} to start each
* new contour. Finally, call {@link net.java.games.jogl.GLU#gluEndPolygon
* gluEndPolygon} to signal the end of the definition. See the
* {@link net.java.games.jogl.GLU#gluTessVertex gluTessVertex} and
* {@link net.java.games.jogl.GLU#gluNextContour gluNextContour} reference
* pages for more details.
* * Once {@link net.java.games.jogl.GLU#gluEndPolygon gluEndPolygon} is called, * the polygon is tessellated, and the resulting triangles are described * through callbacks. See {@link net.java.games.jogl.GLU#gluTessCallback * gluTessCallback} for descriptions of the callback methods. * * @param tesselator * Specifies the tessellation object (created with * {@link net.java.games.jogl.GLU#gluNewTess gluNewTess}). * * @see net.java.games.jogl.GLU#gluNewTess gluNewTess * @see net.java.games.jogl.GLU#gluNextContour gluNextContour * @see net.java.games.jogl.GLU#gluTessCallback gluTessCallback * @see net.java.games.jogl.GLU#gluTessVertex gluTessVertex * @see net.java.games.jogl.GLU#gluTessBeginPolygon gluTessBeginPolygon * @see net.java.games.jogl.GLU#gluTessBeginContour gluTessBeginContour ****************************************************************************/ public void gluBeginPolygon(GLUtesselator tesselator); /***************************************************************************** * gluDeleteTess destroys the indicated tessellation object (which was * created with {@link net.java.games.jogl.GLU#gluNewTess gluNewTess}). * * @param tesselator * Specifies the tessellation object to destroy. * * @see net.java.games.jogl.GLU#gluBeginPolygon gluBeginPolygon * @see net.java.games.jogl.GLU#gluNewTess gluNewTess * @see net.java.games.jogl.GLU#gluTessCallback gluTessCallback ****************************************************************************/ public void gluDeleteTess(GLUtesselator tesselator); /***************************************************************************** * gluEndPolygon and {@link net.java.games.jogl.GLU#gluBeginPolygon * gluBeginPolygon} delimit the definition of a nonconvex polygon. To define * such a polygon, first call {@link net.java.games.jogl.GLU#gluBeginPolygon * gluBeginPolygon}. Then define the contours of the polygon by calling * {@link net.java.games.jogl.GLU#gluTessVertex gluTessVertex} for each vertex * and {@link net.java.games.jogl.GLU#gluNextContour gluNextContour} to start * each new contour. Finally, call gluEndPolygon to signal the end of * the definition. See the {@link net.java.games.jogl.GLU#gluTessVertex * gluTessVertex} and {@link net.java.games.jogl.GLU#gluNextContour * gluNextContour} reference pages for more details.
* * Once gluEndPolygon is called, the polygon is tessellated, and the * resulting triangles are described through callbacks. See * {@link net.java.games.jogl.GLU#gluTessCallback gluTessCallback} for * descriptions of the callback methods. * * @param tesselator * Specifies the tessellation object (created with * {@link net.java.games.jogl.GLU#gluNewTess gluNewTess}). * * @see net.java.games.jogl.GLU#gluNewTess gluNewTess * @see net.java.games.jogl.GLU#gluNextContour gluNextContour * @see net.java.games.jogl.GLU#gluTessCallback gluTessCallback * @see net.java.games.jogl.GLU#gluTessVertex gluTessVertex * @see net.java.games.jogl.GLU#gluTessBeginPolygon gluTessBeginPolygon * @see net.java.games.jogl.GLU#gluTessBeginContour gluTessBeginContour ****************************************************************************/ public void gluEndPolygon(GLUtesselator tesselator); /***************************************************************************** * gluGetTessProperty retrieves properties stored in a tessellation * object. These properties affect the way that tessellation objects are * interpreted and rendered. See the * {@link net.java.games.jogl.GLU#gluTessProperty gluTessProperty} reference * page for information about the properties and what they do. * * @param tesselator * Specifies the tessellation object (created with * {@link net.java.games.jogl.GLU#gluNewTess gluNewTess}). * @param which * Specifies the property whose value is to be fetched. Valid values * are GLU_TESS_WINDING_RULE, GLU_TESS_BOUNDARY_ONLY, * and GLU_TESS_TOLERANCES. * @param value * Specifices an array into which the value of the named property is * written. * * @see net.java.games.jogl.GLU#gluNewTess gluNewTess * @see net.java.games.jogl.GLU#gluTessProperty gluTessProperty ****************************************************************************/ public void gluGetTessProperty(GLUtesselator tesselator, int which, double[] value); /***************************************************************************** * gluNewTess creates and returns a new tessellation object. This * object must be referred to when calling tesselation methods. A return * value of null means that there was not enough memeory to allocate the * object. * * @return A new tessellation object. * * @see net.java.games.jogl.GLU#gluTessBeginPolygon gluTessBeginPolygon * @see net.java.games.jogl.GLU#gluDeleteTess gluDeleteTess * @see net.java.games.jogl.GLU#gluTessCallback gluTessCallback ****************************************************************************/ public GLUtesselator gluNewTess(); /***************************************************************************** * gluNextContour is used to describe polygons with multiple * contours. After you describe the first contour through a series of * {@link net.java.games.jogl.GLU#gluTessVertex gluTessVertex} calls, a * gluNextContour call indicates that the previous contour is complete * and that the next contour is about to begin. Perform another series of * {@link net.java.games.jogl.GLU#gluTessVertex gluTessVertex} calls to * describe the new contour. Repeat this process until all contours have been * described.
* * The type parameter defines what type of contour follows. The following * values are valid.
* * GLU_EXTERIOR *
* * To define the type of the first contour, you can call gluNextContour * before describing the first contour. If you do not call * gluNextContour before the first contour, the first contour is marked * GLU_EXTERIOR.
* *
* * data is a reference to a user-defined data structure. If the * appropriate callback(s) are specified (see * {@link net.java.games.jogl.GLU#gluTessCallback gluTessCallback}), then this * reference is returned to the callback method(s). Thus, it is a convenient * way to store per-polygon information.
* * Once {@link net.java.games.jogl.GLU#gluTessEndPolygon gluTessEndPolygon} is * called, the polygon is tessellated, and the resulting triangles are * described through callbacks. See * {@link net.java.games.jogl.GLU#gluTessCallback gluTessCallback} for * descriptions of the callback methods. * * @param tesselator * Specifies the tessellation object (created with * {@link net.java.games.jogl.GLU#gluNewTess gluNewTess}). * @param data * Specifies a reference to user polygon data. * * @see net.java.games.jogl.GLU#gluNewTess gluNewTess * @see net.java.games.jogl.GLU#gluTessBeginContour gluTessBeginContour * @see net.java.games.jogl.GLU#gluTessVertex gluTessVertex * @see net.java.games.jogl.GLU#gluTessCallback gluTessCallback * @see net.java.games.jogl.GLU#gluTessProperty gluTessProperty * @see net.java.games.jogl.GLU#gluTessNormal gluTessNormal * @see net.java.games.jogl.GLU#gluTessEndPolygon gluTessEndPolygon ****************************************************************************/ public void gluTessBeginPolygon(GLUtesselator tesselator, Object data); /***************************************************************************** * gluTessCallback is used to indicate a callback to be used by a * tessellation object. If the specified callback is already defined, then it * is replaced. If aCallback is null, then the existing callback * becomes undefined.
* * These callbacks are used by the tessellation object to describe how a * polygon specified by the user is broken into triangles. Note that there are * two versions of each callback: one with user-specified polygon data and one * without. If both versions of a particular callback are specified, then the * callback with user-specified polygon data will be used. Note that the * polygonData parameter used by some of the methods is a copy of the * reference that was specified when * {@link net.java.games.jogl.GLU#gluTessBeginPolygon gluTessBeginPolygon} * was called. The legal callbacks are as follows:
* * GLU_TESS_BEGIN *
* void begin(int type);
* * GLU_TESS_BEGIN_DATA *
* void beginData(int type, Object polygonData);* * GLU_TESS_EDGE_FLAG *
* * Since triangle fans and triangle strips do not support edge flags, the * begin callback is not called with GL_TRIANGLE_FAN or * GL_TRIANGLE_STRIP if a non-null edge flag callback is provided. * (If the callback is initialized to null, there is no impact on * performance). Instead, the fans and strips are converted to independent * triangles. The method prototype for this callback is: *
* void edgeFlag(boolean boundaryEdge);* * GLU_TESS_EDGE_FLAG_DATA *
* void edgeFlagData(boolean boundaryEdge, Object polygonData);* * GLU_TESS_VERTEX *
* void vertex(Object vertexData);* * GLU_TESS_VERTEX_DATA *
* void vertexData(Object vertexData, Object polygonData);* * GLU_TESS_END *
* void end();* * GLU_TESS_END_DATA *
* void endData(Object polygonData);* * GLU_TESS_COMBINE *
* void combine(double[] coords, Object[] data, * float[] weight, Object[] outData);* *
* * The user must allocate another vertex, interpolate parameters using * data and weight, and return the new vertex pointer * in outData. This handle is supplied during rendering callbacks. * The user is responsible for freeing the memory some time after * {@link net.java.games.jogl.GLU#gluTessEndPolygon gluTessEndPolygon} is * called.
* * For example, if the polygon lies in an arbitrary plane in 3-space, and a * color is associated with each vertex, the GLU_TESS_COMBINE * callback might look like this: *
* void myCombine(double[] coords, Object[] data, * float[] weight, Object[] outData) * { * MyVertex newVertex = new MyVertex(); * * newVertex.x = coords[0]; * newVertex.y = coords[1]; * newVertex.z = coords[2]; * newVertex.r = weight[0]*data[0].r + * weight[1]*data[1].r + * weight[2]*data[2].r + * weight[3]*data[3].r; * newVertex.g = weight[0]*data[0].g + * weight[1]*data[1].g + * weight[2]*data[2].g + * weight[3]*data[3].g; * newVertex.b = weight[0]*data[0].b + * weight[1]*data[1].b + * weight[2]*data[2].b + * weight[3]*data[3].b; * newVertex.a = weight[0]*data[0].a + * weight[1]*data[1].a + * weight[2]*data[2].a + * weight[3]*data[3].a; * outData = newVertex; * }* *
* void combineData(double[] coords, Object[] data, float[] weight, Object[] outData, Object polygonData);* * GLU_TESS_ERROR *
* void error(int errnum);* *
* void errorData(int errnum, Object polygonData);* * @param tesselator * Specifies the tessellation object (created with * {@link net.java.games.jogl.GLU#gluNewTess gluNewTess}). * @param which * Specifies the callback being defined. The following values are * valid: GLU_TESS_BEGIN, GLU_TESS_BEGIN_DATA, * GLU_TESS_EDGE_FLAG, GLU_TESS_EDGE_FLAG_DATA, * GLU_TESS_VERTEX, GLU_TESS_VERTEX_DATA, * GLU_TESS_END, GLU_TESS_END_DATA, * GLU_TESS_COMBINE, GLU_TESS_COMBINE_DATA, * GLU_TESS_ERROR, and GLU_TESS_ERROR_DATA. * @param aCallback * Specifies the callback object to be called. * * @see net.java.games.jogl.GL#glBegin glBegin * @see net.java.games.jogl.GL#glEdgeFlag glEdgeFlag * @see net.java.games.jogl.GL#glVertex3f glVertex3f * @see net.java.games.jogl.GLU#gluNewTess gluNewTess * @see net.java.games.jogl.GLU#gluErrorString gluErrorString * @see net.java.games.jogl.GLU#gluTessVertex gluTessVertex * @see net.java.games.jogl.GLU#gluTessBeginPolygon gluTessBeginPolygon * @see net.java.games.jogl.GLU#gluTessBeginContour gluTessBeginContour * @see net.java.games.jogl.GLU#gluTessProperty gluTessProperty * @see net.java.games.jogl.GLU#gluTessNormal gluTessNormal ****************************************************************************/ public void gluTessCallback(GLUtesselator tesselator, int which, GLUtesselatorCallback aCallback); /***************************************************************************** * gluTessEndContour and * {@link net.java.games.jogl.GLU#gluTessBeginContour gluTessBeginContour} * delimit the definition of a polygon contour. Within each * {@link net.java.games.jogl.GLU#gluTessBeginContour gluTessBeginContour}/ * gluTessEndContour pair, there can be zero or more calls to * {@link net.java.games.jogl.GLU#gluTessVertex gluTessVertex}. The vertices * specify a closed contour (the last vertex of each contour is automatically * linked to the first). See the {@link net.java.games.jogl.GLU#gluTessVertex * gluTessVertex} reference page for more details. * {@link net.java.games.jogl.GLU#gluTessBeginContour gluTessBeginContour} can * only be called between {@link net.java.games.jogl.GLU#gluTessBeginPolygon * gluTessBeginPolygon} and * {@link net.java.games.jogl.GLU#gluTessEndPolygon gluTessEndPolygon}. * * @param tesselator * Specifies the tessellation object (created with * {@link net.java.games.jogl.GLU#gluNewTess gluNewTess}). * * @see net.java.games.jogl.GLU#gluNewTess gluNewTess * @see net.java.games.jogl.GLU#gluTessBeginPolygon gluTessBeginPolygon * @see net.java.games.jogl.GLU#gluTessVertex gluTessVertex * @see net.java.games.jogl.GLU#gluTessCallback gluTessCallback * @see net.java.games.jogl.GLU#gluTessProperty gluTessProperty * @see net.java.games.jogl.GLU#gluTessNormal gluTessNormal * @see net.java.games.jogl.GLU#gluTessEndPolygon gluTessEndPolygon ****************************************************************************/ public void gluTessEndContour(GLUtesselator tesselator); /***************************************************************************** * gluTessEndPolygon and * {@link net.java.games.jogl.GLU#gluTessBeginPolygon gluTessBeginPolygon} * delimit the definition of a convex, concave or self-intersecting polygon. * Within each {@link net.java.games.jogl.GLU#gluTessBeginPolygon * gluTessBeginPolygon}/gluTessEndPolygon pair, there must be one or * more calls to {@link net.java.games.jogl.GLU#gluTessBeginContour * gluTessBeginContour}/{@link net.java.games.jogl.GLU#gluTessEndContour * gluTessEndContour}. Within each contour, there are zero or more calls to * {@link net.java.games.jogl.GLU#gluTessVertex gluTessVertex}. The vertices * specify a closed contour (the last vertex of each contour is automatically * linked to the first). See the {@link net.java.games.jogl.GLU#gluTessVertex * gluTessVertex}, {@link net.java.games.jogl.GLU#gluTessBeginContour * gluTessBeginContour} and {@link net.java.games.jogl.GLU#gluTessEndContour * gluTessEndContour} reference pages for more details.
* * Once gluTessEndPolygon is called, the polygon is tessellated, and * the resulting triangles are described through callbacks. See * {@link net.java.games.jogl.GLU#gluTessCallback gluTessCallback} for * descriptions of the callback functions. * * @param tesselator * Specifies the tessellation object (created with * {@link net.java.games.jogl.GLU#gluNewTess gluNewTess}). * * @see net.java.games.jogl.GLU#gluNewTess gluNewTess * @see net.java.games.jogl.GLU#gluTessBeginContour gluTessBeginContour * @see net.java.games.jogl.GLU#gluTessVertex gluTessVertex * @see net.java.games.jogl.GLU#gluTessCallback gluTessCallback * @see net.java.games.jogl.GLU#gluTessProperty gluTessProperty * @see net.java.games.jogl.GLU#gluTessNormal gluTessNormal * @see net.java.games.jogl.GLU#gluTessBeginPolygon gluTessBeginPolygon ****************************************************************************/ public void gluTessEndPolygon(GLUtesselator tesselator); /***************************************************************************** * gluTessNormal describes a normal for a polygon that the program is * defining. All input data will be projected onto a plane perpendicular to * the one of the three coordinate axes before tessellation and all output * triangles will be oriented CCW with repsect to the normal (CW orientation * can be obtained by reversing the sign of the supplied normal). For * example, if you know that all polygons lie in the x-y plane, call * gluTessNormal(tess, 0.0, 0.0, 0.0) before rendering any polygons.
* * If the supplied normal is (0.0, 0.0, 0.0)(the initial value), the normal * is determined as follows. The direction of the normal, up to its sign, is * found by fitting a plane to the vertices, without regard to how the * vertices are connected. It is expected that the input data lies * approximately in the plane; otherwise, projection perpendicular to one of * the three coordinate axes may substantially change the geometry. The sign * of the normal is chosen so that the sum of the signed areas of all input * contours is nonnegative (where a CCW contour has positive area).
* * The supplied normal persists until it is changed by another call to * gluTessNormal. * * @param tesselator * Specifies the tessellation object (created by * {@link net.java.games.jogl.GLU#gluNewTess gluNewTess}). * @param x * Specifies the first component of the normal. * @param y * Specifies the second component of the normal. * @param z * Specifies the third component of the normal. * * @see net.java.games.jogl.GLU#gluTessBeginPolygon gluTessBeginPolygon * @see net.java.games.jogl.GLU#gluTessEndPolygon gluTessEndPolygon ****************************************************************************/ public void gluTessNormal(GLUtesselator tesselator, double x, double y, double z); /***************************************************************************** * gluTessProperty is used to control properites stored in a * tessellation object. These properties affect the way that the polygons are * interpreted and rendered. The legal value for which are as * follows:
* * GLU_TESS_WINDING_RULE *
* * To understand how the winding rule works, consider that the input * contours partition the plane into regions. The winding rule determines * which of these regions are inside the polygon.
* * For a single contour C, the winding number of a point x is simply the * signed number of revolutions we make around x as we travel once around C * (where CCW is positive). When there are several contours, the individual * winding numbers are summed. This procedure associates a signed integer * value with each point x in the plane. Note that the winding number is * the same for all points in a single region.
* * The winding rule classifies a region as "inside" if its winding number * belongs to the chosen category (odd, nonzero, positive, negative, or * absolute value of at least two). The previous GLU tesselator (prior to * GLU 1.2) used the "odd" rule. The "nonzero" rule is another common way * to define the interior. The other three rules are useful for polygon CSG * operations. *
* * Feature merging is completely optional; the tolerance is only a hint. * The implementation is free to merge in some cases and not in others, or * to never merge features at all. The initial tolerance is 0.
* * The current implementation merges vertices only if they are exactly * coincident, regardless of the current tolerance. A vertex is spliced * into an edge only if the implementation is unable to distinguish which * side of the edge the vertex lies on. Two edges are merged only when both * endpoints are identical. *
* * data normally references to a structure containing the vertex * location, as well as other per-vertex attributes such as color and normal. * This reference is passed back to the user through the * GLU_TESS_VERTEX or GLU_TESS_VERTEX_DATA callback after * tessellation (see the {@link net.java.games.jogl.GLU#gluTessCallback * gluTessCallback} reference page). * * @param tesselator * Specifies the tessellation object (created with * {@link net.java.games.jogl.GLU#gluNewTess gluNewTess}). * @param coords * Specifies the coordinates of the vertex. * @param data * Specifies an opaque reference passed back to the program with the * vertex callback (as specified by * {@link net.java.games.jogl.GLU#gluTessCallback gluTessCallback}). * * @see net.java.games.jogl.GLU#gluTessBeginPolygon gluTessBeginPolygon * @see net.java.games.jogl.GLU#gluNewTess gluNewTess * @see net.java.games.jogl.GLU#gluTessBeginContour gluTessBeginContour * @see net.java.games.jogl.GLU#gluTessCallback gluTessCallback * @see net.java.games.jogl.GLU#gluTessProperty gluTessProperty * @see net.java.games.jogl.GLU#gluTessNormal gluTessNormal * @see net.java.games.jogl.GLU#gluTessEndPolygon gluTessEndPolygon ****************************************************************************/ public void gluTessVertex(GLUtesselator tesselator, double[] coords, Object data); /** * Returns true if the specified GLU core- or extension-function can be * successfully used through this GLU instance. By "successfully" we mean * that the function is both callable on the machine running the * program and available on the current display.
* * A GLU function is callable if it is a GLU core- or extension-function * that is supported by the underlying GLU implementation. The function is * available if the OpenGL implementation on the display meets the * requirements of the GLU function being called (because GLU functions utilize * OpenGL functions).
* * Whether or not a GLU function is callable is determined as follows: *
gluGetString(GLU_VERSION)
is used to determine the
* version number of the underlying GLU implementation on the host.
* then the function name is cross-referenced with that specification to
* see if it is part of that version's specification.
*
* gluGetString(GLU_EXTENSIONS)
to see if the function is one of
* the extensions that is supported by the underlying GLU implementation.
* glGetString(GL_VERSION)
is used to determine the
* highest OpenGL version that both host and display support, and from that it
* is possible to determine if the GL facilities required by the GLU function
* are available on the display.
*
* gluGetString(GLU_EXTENSIONS)
to see if the function is one of
* the extensions that is supported by the underlying GLU implementation.
*
* gluNurbsCallbackDataEXT(GLUnurbs, GLvoid)
extension is available).
*/
public boolean isFunctionAvailable(String gluFunctionName);