1 private static boolean useJavaMipmapCode = true;
2
3 static {
AccessController.doPrivileged(new PrivilegedAction() { public Object run() { String val = System.getProperty(R); if (val != null && !val.toLowerCase().equals(R)) { useJavaMipmapCode = false; } return null; } })4 AccessController.doPrivileged(new PrivilegedAction() {
5 public Object run() {
6 String val = System.getProperty("jogl.glu.nojava");
7 if (val != null && !val.toLowerCase().equals("false")) {
8 useJavaMipmapCode = false;
9 }
10 return null;
11 }
12 });
13 }
14
15 /**
16 * Instantiates a new OpenGL Utility Library object. A GLU object may
17 * be instantiated at any point in the application and is not
18 * inherently tied to any particular OpenGL context; however, the GLU
19 * object may only be used when an OpenGL context is current on the
20 * current thread. Attempts to call most of the methods in the GLU
21 * library when no OpenGL context is current will cause an exception
22 * to be thrown.
23 *
24 * <P>
25 *
26 * The returned GLU object is not guaranteed to be thread-safe and
27 * should only be used from one thread at a time. Multiple GLU objects
28 * may be instantiated to be used from different threads
29 * simultaneously.
30 */
31
GLU()32 public GLU()
33 {
34 this.project = new Project();
35 }
36
37 //----------------------------------------------------------------------
38 // Utility routines
39 //
40
41 /**
42 * Returns the GL object associated with the OpenGL context current on
43 * the current thread. Throws GLException if no OpenGL context is
44 * current.
45 */
46
getCurrentGL()47 public static GL getCurrentGL() throws GLException {
48 GLContext curContext = GLContext.getCurrent();
49 if (curContext == null) {
50 throw new GLException("No OpenGL context current on this thread");
51 }
52 return curContext.getGL();
53 }
54
gluErrorString(int errorCode)55 public String gluErrorString(int errorCode) {
56 return Error.gluErrorString(errorCode);
57 }
58
59 /* extName is an extension name.
60 * extString is a string of extensions separated by blank(s). There may or
61 * may not be leading or trailing blank(s) in extString.
62 * This works in cases of extensions being prefixes of another like
63 * GL_EXT_texture and GL_EXT_texture3D.
64 * Returns true if extName is found otherwise it returns false.
65 */
gluCheckExtension(java.lang.String extName, java.lang.String extString)66 public boolean gluCheckExtension(java.lang.String extName, java.lang.String extString) {
67 return Registry.gluCheckExtension(extName, extString);
68 }
69
gluGetString(int name)70 public String gluGetString(int name) {
71 return Registry.gluGetString(name);
72 }
73
74 /**
75 * Returns true if the specified GLU core- or extension-function can be
76 * successfully used through this GLU instance. By "successfully" we mean
77 * that the function is both <i>callable</i> on the machine running the
78 * program and <i>available</i> on the current display.<P>
79 *
80 * A GLU function is <i>callable</i> if it is a GLU core- or extension-function
81 * that is supported by the underlying GLU implementation. The function is
82 * <i>available</i> if the OpenGL implementation on the display meets the
83 * requirements of the GLU function being called (because GLU functions utilize
84 * OpenGL functions). <P>
85 *
86 * Whether or not a GLU function is <i>callable</i> is determined as follows:
87 * <ul>
88 * <li>If the function is a GLU core function (i.e., not an
89 * extension), <code>gluGetString(GLU_VERSION)</code> is used to determine the
90 * version number of the underlying GLU implementation on the host.
91 * then the function name is cross-referenced with that specification to
92 * see if it is part of that version's specification.
93 *
94 * <li> If the function is a GLU extension, the function name is
95 * cross-referenced with the list returned by
96 * <code>gluGetString(GLU_EXTENSIONS)</code> to see if the function is one of
97 * the extensions that is supported by the underlying GLU implementation.
98 * </ul>
99 *
100 * Whether or not a GLU function is <i>available</i> is determined as follows:
101 * <ul>
102 * <li>If the function is a GLU core function then the function is first
103 * cross-referenced with the GLU specifications to find the minimum GLU
104 * version required to <i>call</i> that GLU function. Then the following table
105 * is consulted to determine the minimum GL version required for that version
106 * of GLU:
107 * <ul>
108 * <li> GLU 1.0 requires OpenGL 1.0
109 * <li> GLU 1.1 requires OpenGL 1.0
110 * <li> GLU 1.2 requires OpenGL 1.1
111 * <li> GLU 1.3 requires OpenGL 1.2
112 * </ul>
113 * Finally, <code>glGetString(GL_VERSION)</code> is used to determine the
114 * highest OpenGL version that both host and display support, and from that it
115 * is possible to determine if the GL facilities required by the GLU function
116 * are <i>available</i> on the display.
117 *
118 * <li> If the function is a GLU extension, the function name is
119 * cross-referenced with the list returned by
120 * <code>gluGetString(GLU_EXTENSIONS)</code> to see if the function is one of
121 * the extensions that is supported by the underlying GLU implementation.
122 * </ul>
123 *
124 * <b>NOTE:</b>The availability of a function may change at runtime in
125 * response to changes in the display environment. For example, when a window
126 * is dragged from one display to another on a multi-display system, or when
127 * the properties of the display device are modified (e.g., changing the color
128 * depth of the display). Any application that is concerned with handling
129 * these situations correctly should confirm availability after a display
130 * change before calling a questionable OpenGL function. To detect a change in
131 * the display device, please see {@link
132 * GLEventListener#displayChanged(GLAutoDrawable,boolean,boolean)}.
133 *
134 * @param gluFunctionName the name of the OpenGL function (e.g., use
135 * "gluNurbsCallbackDataEXT" to check if the <code>
136 * gluNurbsCallbackDataEXT(GLUnurbs, GLvoid)</code> extension is available).
137 */
isFunctionAvailable(String gluFunctionName)138 public boolean isFunctionAvailable(String gluFunctionName)
139 {
140 if (useJavaMipmapCode) {
141 // All GLU functions are available in Java port
142 return true;
143 }
144 return (gluProcAddressTable.getAddressFor(gluFunctionName) != 0);
145 }
146
147 //----------------------------------------------------------------------
148 // Tessellation routines
149 //
150
151 /*****************************************************************************
152 * <b>gluNewTess</b> creates and returns a new tessellation object. This
153 * object must be referred to when calling tesselation methods. A return
154 * value of null means that there was not enough memeory to allocate the
155 * object.
156 *
157 * @return A new tessellation object.
158 *
159 * @see #gluTessBeginPolygon gluTessBeginPolygon
160 * @see #gluDeleteTess gluDeleteTess
161 * @see #gluTessCallback gluTessCallback
162 ****************************************************************************/
gluNewTess()163 public GLUtessellator gluNewTess() {
164 return GLUtessellatorImpl.gluNewTess();
165 }
166
167 /*****************************************************************************
168 * <b>gluDeleteTess</b> destroys the indicated tessellation object (which was
169 * created with {@link #gluNewTess gluNewTess}).
170 *
171 * @param tessellator
172 * Specifies the tessellation object to destroy.
173 *
174 * @see #gluBeginPolygon gluBeginPolygon
175 * @see #gluNewTess gluNewTess
176 * @see #gluTessCallback gluTessCallback
177 ****************************************************************************/
gluDeleteTess(GLUtessellator tessellator)178 public void gluDeleteTess(GLUtessellator tessellator) {
179 GLUtessellatorImpl tess = (GLUtessellatorImpl) tessellator;
180 tess.gluDeleteTess();
181 }
182
183 /*****************************************************************************
184 * <b>gluTessProperty</b> is used to control properites stored in a
185 * tessellation object. These properties affect the way that the polygons are
186 * interpreted and rendered. The legal value for <i>which</i> are as
187 * follows:<P>
188 *
189 * <b>GLU_TESS_WINDING_RULE</b>
190 * <UL>
191 * Determines which parts of the polygon are on the "interior".
192 * <em>value</em> may be set to one of
193 * <BR><b>GLU_TESS_WINDING_ODD</b>,
194 * <BR><b>GLU_TESS_WINDING_NONZERO</b>,
195 * <BR><b>GLU_TESS_WINDING_POSITIVE</b>, or
196 * <BR><b>GLU_TESS_WINDING_NEGATIVE</b>, or
197 * <BR><b>GLU_TESS_WINDING_ABS_GEQ_TWO</b>.<P>
198 *
199 * To understand how the winding rule works, consider that the input
200 * contours partition the plane into regions. The winding rule determines
201 * which of these regions are inside the polygon.<P>
202 *
203 * For a single contour C, the winding number of a point x is simply the
204 * signed number of revolutions we make around x as we travel once around C
205 * (where CCW is positive). When there are several contours, the individual
206 * winding numbers are summed. This procedure associates a signed integer
207 * value with each point x in the plane. Note that the winding number is
208 * the same for all points in a single region.<P>
209 *
210 * The winding rule classifies a region as "inside" if its winding number
211 * belongs to the chosen category (odd, nonzero, positive, negative, or
212 * absolute value of at least two). The previous GLU tessellator (prior to
213 * GLU 1.2) used the "odd" rule. The "nonzero" rule is another common way
214 * to define the interior. The other three rules are useful for polygon CSG
215 * operations.
216 * </UL>
217 * <BR><b>GLU_TESS_BOUNDARY_ONLY</b>
218 * <UL>
219 * Is a boolean value ("value" should be set to GL_TRUE or GL_FALSE). When
220 * set to GL_TRUE, a set of closed contours separating the polygon interior
221 * and exterior are returned instead of a tessellation. Exterior contours
222 * are oriented CCW with respect to the normal; interior contours are
223 * oriented CW. The <b>GLU_TESS_BEGIN</b> and <b>GLU_TESS_BEGIN_DATA</b>
224 * callbacks use the type GL_LINE_LOOP for each contour.
225 * </UL>
226 * <BR><b>GLU_TESS_TOLERANCE</b>
227 * <UL>
228 * Specifies a tolerance for merging features to reduce the size of the
229 * output. For example, two vertices that are very close to each other
230 * might be replaced by a single vertex. The tolerance is multiplied by the
231 * largest coordinate magnitude of any input vertex; this specifies the
232 * maximum distance that any feature can move as the result of a single
233 * merge operation. If a single feature takes part in several merge
234 * operations, the toal distance moved could be larger.<P>
235 *
236 * Feature merging is completely optional; the tolerance is only a hint.
237 * The implementation is free to merge in some cases and not in others, or
238 * to never merge features at all. The initial tolerance is 0.<P>
239 *
240 * The current implementation merges vertices only if they are exactly
241 * coincident, regardless of the current tolerance. A vertex is spliced
242 * into an edge only if the implementation is unable to distinguish which
243 * side of the edge the vertex lies on. Two edges are merged only when both
244 * endpoints are identical.
245 * </UL>
246 *
247 * @param tessellator
248 * Specifies the tessellation object created with
249 * {@link #gluNewTess gluNewTess}
250 * @param which
251 * Specifies the property to be set. Valid values are
252 * <b>GLU_TESS_WINDING_RULE</b>, <b>GLU_TESS_BOUNDARDY_ONLY</b>,
253 * <b>GLU_TESS_TOLERANCE</b>.
254 * @param value
255 * Specifices the value of the indicated property.
256 *
257 * @see #gluGetTessProperty gluGetTessProperty
258 * @see #gluNewTess gluNewTess
259 ****************************************************************************/
gluTessProperty(GLUtessellator tessellator, int which, double value)260 public void gluTessProperty(GLUtessellator tessellator, int which, double value) {
261 GLUtessellatorImpl tess = (GLUtessellatorImpl) tessellator;
262 tess.gluTessProperty(which, value);
263 }
264
265 /*****************************************************************************
266 * <b>gluGetTessProperty</b> retrieves properties stored in a tessellation
267 * object. These properties affect the way that tessellation objects are
268 * interpreted and rendered. See the
269 * {@link #gluTessProperty gluTessProperty} reference
270 * page for information about the properties and what they do.
271 *
272 * @param tessellator
273 * Specifies the tessellation object (created with
274 * {@link #gluNewTess gluNewTess}).
275 * @param which
276 * Specifies the property whose value is to be fetched. Valid values
277 * are <b>GLU_TESS_WINDING_RULE</b>, <b>GLU_TESS_BOUNDARY_ONLY</b>,
278 * and <b>GLU_TESS_TOLERANCES</b>.
279 * @param value
280 * Specifices an array into which the value of the named property is
281 * written.
282 *
283 * @see #gluNewTess gluNewTess
284 * @see #gluTessProperty gluTessProperty
285 ****************************************************************************/
gluGetTessProperty(GLUtessellator tessellator, int which, double[] value, int value_offset)286 public void gluGetTessProperty(GLUtessellator tessellator, int which, double[] value, int value_offset) {
287 GLUtessellatorImpl tess = (GLUtessellatorImpl) tessellator;
288 tess.gluGetTessProperty(which, value, value_offset);
289 }
290
291 /*****************************************************************************
292 * <b>gluTessNormal</b> describes a normal for a polygon that the program is
293 * defining. All input data will be projected onto a plane perpendicular to
294 * the one of the three coordinate axes before tessellation and all output
295 * triangles will be oriented CCW with repsect to the normal (CW orientation
296 * can be obtained by reversing the sign of the supplied normal). For
297 * example, if you know that all polygons lie in the x-y plane, call
298 * <b>gluTessNormal</b>(tess, 0.0, 0.0, 0.0) before rendering any polygons.<P>
299 *
300 * If the supplied normal is (0.0, 0.0, 0.0)(the initial value), the normal
301 * is determined as follows. The direction of the normal, up to its sign, is
302 * found by fitting a plane to the vertices, without regard to how the
303 * vertices are connected. It is expected that the input data lies
304 * approximately in the plane; otherwise, projection perpendicular to one of
305 * the three coordinate axes may substantially change the geometry. The sign
306 * of the normal is chosen so that the sum of the signed areas of all input
307 * contours is nonnegative (where a CCW contour has positive area).<P>
308 *
309 * The supplied normal persists until it is changed by another call to
310 * <b>gluTessNormal</b>.
311 *
312 * @param tessellator
313 * Specifies the tessellation object (created by
314 * {@link #gluNewTess gluNewTess}).
315 * @param x
316 * Specifies the first component of the normal.
317 * @param y
318 * Specifies the second component of the normal.
319 * @param z
320 * Specifies the third component of the normal.
321 *
322 * @see #gluTessBeginPolygon gluTessBeginPolygon
323 * @see #gluTessEndPolygon gluTessEndPolygon
324 ****************************************************************************/
gluTessNormal(GLUtessellator tessellator, double x, double y, double z)325 public void gluTessNormal(GLUtessellator tessellator, double x, double y, double z) {
326 GLUtessellatorImpl tess = (GLUtessellatorImpl) tessellator;
327 tess.gluTessNormal(x, y, z);
328 }
329
330 /*****************************************************************************
331 * <b>gluTessCallback</b> is used to indicate a callback to be used by a
332 * tessellation object. If the specified callback is already defined, then it
333 * is replaced. If <i>aCallback</i> is null, then the existing callback
334 * becomes undefined.<P>
335 *
336 * These callbacks are used by the tessellation object to describe how a
337 * polygon specified by the user is broken into triangles. Note that there are
338 * two versions of each callback: one with user-specified polygon data and one
339 * without. If both versions of a particular callback are specified, then the
340 * callback with user-specified polygon data will be used. Note that the
341 * polygonData parameter used by some of the methods is a copy of the
342 * reference that was specified when
343 * {@link #gluTessBeginPolygon gluTessBeginPolygon}
344 * was called. The legal callbacks are as follows:<P>
345 *
346 * <b>GLU_TESS_BEGIN</b>
347 * <UL>
348 * The begin callback is invoked like {@link javax.media.opengl.GL#glBegin
349 * glBegin} to indicate the start of a (triangle) primitive. The method
350 * takes a single argument of type int. If the
351 * <b>GLU_TESS_BOUNDARY_ONLY</b> property is set to <b>GL_FALSE</b>, then
352 * the argument is set to either <b>GL_TRIANGLE_FAN</b>,
353 * <b>GL_TRIANGLE_STRIP</b>, or <b>GL_TRIANGLES</b>. If the
354 * <b>GLU_TESS_BOUNDARY_ONLY</b> property is set to <b>GL_TRUE</b>, then the
355 * argument will be set to <b>GL_LINE_LOOP</b>. The method prototype for
356 * this callback is:
357 * </UL>
358 *
359 * <PRE>
360 * void begin(int type);</PRE><P>
361 *
362 * <b>GLU_TESS_BEGIN_DATA</b>
363 * <UL>
364 * The same as the <b>GLU_TESS_BEGIN</b> callback except
365 * that it takes an additional reference argument. This reference is
366 * identical to the opaque reference provided when
367 * {@link #gluTessBeginPolygon gluTessBeginPolygon}
368 * was called. The method prototype for this callback is:
369 * </UL>
370 *
371 * <PRE>
372 * void beginData(int type, Object polygonData);</PRE>
373 *
374 * <b>GLU_TESS_EDGE_FLAG</b>
375 * <UL>
376 * The edge flag callback is similar to
377 * {@link javax.media.opengl.GL#glEdgeFlag glEdgeFlag}. The method takes
378 * a single boolean boundaryEdge that indicates which edges lie on the
379 * polygon boundary. If the boundaryEdge is <b>GL_TRUE</b>, then each vertex
380 * that follows begins an edge that lies on the polygon boundary, that is,
381 * an edge that separates an interior region from an exterior one. If the
382 * boundaryEdge is <b>GL_FALSE</b>, then each vertex that follows begins an
383 * edge that lies in the polygon interior. The edge flag callback (if
384 * defined) is invoked before the first vertex callback.<P>
385 *
386 * Since triangle fans and triangle strips do not support edge flags, the
387 * begin callback is not called with <b>GL_TRIANGLE_FAN</b> or
388 * <b>GL_TRIANGLE_STRIP</b> if a non-null edge flag callback is provided.
389 * (If the callback is initialized to null, there is no impact on
390 * performance). Instead, the fans and strips are converted to independent
391 * triangles. The method prototype for this callback is:
392 * </UL>
393 *
394 * <PRE>
395 * void edgeFlag(boolean boundaryEdge);</PRE>
396 *
397 * <b>GLU_TESS_EDGE_FLAG_DATA</b>
398 * <UL>
399 * The same as the <b>GLU_TESS_EDGE_FLAG</b> callback except that it takes
400 * an additional reference argument. This reference is identical to the
401 * opaque reference provided when
402 * {@link #gluTessBeginPolygon gluTessBeginPolygon}
403 * was called. The method prototype for this callback is:
404 * </UL>
405 *
406 * <PRE>
407 * void edgeFlagData(boolean boundaryEdge, Object polygonData);</PRE>
408 *
409 * <b>GLU_TESS_VERTEX</b>
410 * <UL>
411 * The vertex callback is invoked between the begin and end callbacks. It is
412 * similar to {@link javax.media.opengl.GL#glVertex3f glVertex3f}, and it
413 * defines the vertices of the triangles created by the tessellation
414 * process. The method takes a reference as its only argument. This
415 * reference is identical to the opaque reference provided by the user when
416 * the vertex was described (see
417 * {@link #gluTessVertex gluTessVertex}). The method
418 * prototype for this callback is:
419 * </UL>
420 *
421 * <PRE>
422 * void vertex(Object vertexData);</PRE>
423 *
424 * <b>GLU_TESS_VERTEX_DATA</b>
425 * <UL>
426 * The same as the <b>GLU_TESS_VERTEX</b> callback except that it takes an
427 * additional reference argument. This reference is identical to the opaque
428 * reference provided when
429 * {@link #gluTessBeginPolygon gluTessBeginPolygon}
430 * was called. The method prototype for this callback is:
431 * </UL>
432 *
433 * <PRE>
434 * void vertexData(Object vertexData, Object polygonData);</PRE>
435 *
436 * <b>GLU_TESS_END</b>
437 * <UL>
438 * The end callback serves the same purpose as
439 * {@link javax.media.opengl.GL#glEnd glEnd}. It indicates the end of a
440 * primitive and it takes no arguments. The method prototype for this
441 * callback is:
442 * </UL>
443 *
444 * <PRE>
445 * void end();</PRE>
446 *
447 * <b>GLU_TESS_END_DATA</b>
448 * <UL>
449 * The same as the <b>GLU_TESS_END</b> callback except that it takes an
450 * additional reference argument. This reference is identical to the opaque
451 * reference provided when
452 * {@link #gluTessBeginPolygon gluTessBeginPolygon}
453 * was called. The method prototype for this callback is:
454 * </UL>
455 *
456 * <PRE>
457 * void endData(Object polygonData);</PRE>
458 *
459 * <b>GLU_TESS_COMBINE</b>
460 * <UL>
461 * The combine callback is called to create a new vertex when the
462 * tessellation detects an intersection, or wishes to merge features. The
463 * method takes four arguments: an array of three elements each of type
464 * double, an array of four references, an array of four elements each of
465 * type float, and a reference to a reference. The prototype is:
466 * </UL>
467 *
468 * <PRE>
469 * void combine(double[] coords, Object[] data,
470 * float[] weight, Object[] outData);</PRE>
471 *
472 * <UL>
473 * The vertex is defined as a linear combination of up to four existing
474 * vertices, stored in <i>data</i>. The coefficients of the linear
475 * combination are given by <i>weight</i>; these weights always add up to 1.
476 * All vertex pointers are valid even when some of the weights are 0.
477 * <i>coords</i> gives the location of the new vertex.<P>
478 *
479 * The user must allocate another vertex, interpolate parameters using
480 * <i>data</i> and <i>weight</i>, and return the new vertex pointer
481 * in <i>outData</i>. This handle is supplied during rendering callbacks.
482 * The user is responsible for freeing the memory some time after
483 * {@link #gluTessEndPolygon gluTessEndPolygon} is
484 * called.<P>
485 *
486 * For example, if the polygon lies in an arbitrary plane in 3-space, and a
487 * color is associated with each vertex, the <b>GLU_TESS_COMBINE</b>
488 * callback might look like this:
489 * </UL>
490 * <PRE>
491 * void myCombine(double[] coords, Object[] data,
492 * float[] weight, Object[] outData)
493 * {
494 * MyVertex newVertex = new MyVertex();
495 *
496 * newVertex.x = coords[0];
497 * newVertex.y = coords[1];
498 * newVertex.z = coords[2];
499 * newVertex.r = weight[0]*data[0].r +
500 * weight[1]*data[1].r +
501 * weight[2]*data[2].r +
502 * weight[3]*data[3].r;
503 * newVertex.g = weight[0]*data[0].g +
504 * weight[1]*data[1].g +
505 * weight[2]*data[2].g +
506 * weight[3]*data[3].g;
507 * newVertex.b = weight[0]*data[0].b +
508 * weight[1]*data[1].b +
509 * weight[2]*data[2].b +
510 * weight[3]*data[3].b;
511 * newVertex.a = weight[0]*data[0].a +
512 * weight[1]*data[1].a +
513 * weight[2]*data[2].a +
514 * weight[3]*data[3].a;
515 * outData = newVertex;
516 * }</PRE>
517 *
518 * <UL>
519 * If the tessellation detects an intersection, then the
520 * <b>GLU_TESS_COMBINE</b> or <b>GLU_TESS_COMBINE_DATA</b> callback (see
521 * below) must be defined, and it must write a non-null reference into
522 * <i>outData</i>. Otherwise the <b>GLU_TESS_NEED_COMBINE_CALLBACK</b> error
523 * occurs, and no output is generated.
524 * </UL>
525 *
526 * <b>GLU_TESS_COMBINE_DATA</b>
527 * <UL>
528 * The same as the <b>GLU_TESS_COMBINE</b> callback except that it takes an
529 * additional reference argument. This reference is identical to the opaque
530 * reference provided when
531 * {@link #gluTessBeginPolygon gluTessBeginPolygon}
532 * was called. The method prototype for this callback is:
533 * </UL>
534 *
535 * <PRE>
536 * void combineData(double[] coords, Object[] data,
537 float[] weight, Object[] outData,
538 Object polygonData);</PRE>
539 *
540 * <b>GLU_TESS_ERROR</b>
541 * <UL>
542 * The error callback is called when an error is encountered. The one
543 * argument is of type int; it indicates the specific error that occurred
544 * and will be set to one of <b>GLU_TESS_MISSING_BEGIN_POLYGON</b>,
545 * <b>GLU_TESS_MISSING_END_POLYGON</b>,
546 * <b>GLU_TESS_MISSING_BEGIN_CONTOUR</b>,
547 * <b>GLU_TESS_MISSING_END_CONTOUR</b>, <b>GLU_TESS_COORD_TOO_LARGE</b>,
548 * <b>GLU_TESS_NEED_COMBINE_CALLBACK</b> or <b>GLU_OUT_OF_MEMORY</b>.
549 * Character strings describing these errors can be retrieved with the
550 * {@link #gluErrorString gluErrorString} call. The
551 * method prototype for this callback is:
552 * </UL>
553 *
554 * <PRE>
555 * void error(int errnum);</PRE>
556 *
557 * <UL>
558 * The GLU library will recover from the first four errors by inserting the
559 * missing call(s). <b>GLU_TESS_COORD_TOO_LARGE</b> indicates that some
560 * vertex coordinate exceeded the predefined constant
561 * <b>GLU_TESS_MAX_COORD</b> in absolute value, and that the value has been
562 * clamped. (Coordinate values must be small enough so that two can be
563 * multiplied together without overflow.)
564 * <b>GLU_TESS_NEED_COMBINE_CALLBACK</b> indicates that the tessellation
565 * detected an intersection between two edges in the input data, and the
566 * <b>GLU_TESS_COMBINE</b> or <b>GLU_TESS_COMBINE_DATA</b> callback was not
567 * provided. No output is generated. <b>GLU_OUT_OF_MEMORY</b> indicates that
568 * there is not enough memory so no output is generated.
569 * </UL>
570 *
571 * <b>GLU_TESS_ERROR_DATA</b>
572 * <UL>
573 * The same as the GLU_TESS_ERROR callback except that it takes an
574 * additional reference argument. This reference is identical to the opaque
575 * reference provided when
576 * {@link #gluTessBeginPolygon gluTessBeginPolygon}
577 * was called. The method prototype for this callback is:
578 * </UL>
579 *
580 * <PRE>
581 * void errorData(int errnum, Object polygonData);</PRE>
582 *
583 * @param tessellator
584 * Specifies the tessellation object (created with
585 * {@link #gluNewTess gluNewTess}).
586 * @param which
587 * Specifies the callback being defined. The following values are
588 * valid: <b>GLU_TESS_BEGIN</b>, <b>GLU_TESS_BEGIN_DATA</b>,
589 * <b>GLU_TESS_EDGE_FLAG</b>, <b>GLU_TESS_EDGE_FLAG_DATA</b>,
590 * <b>GLU_TESS_VERTEX</b>, <b>GLU_TESS_VERTEX_DATA</b>,
591 * <b>GLU_TESS_END</b>, <b>GLU_TESS_END_DATA</b>,
592 * <b>GLU_TESS_COMBINE</b>, <b>GLU_TESS_COMBINE_DATA</b>,
593 * <b>GLU_TESS_ERROR</b>, and <b>GLU_TESS_ERROR_DATA</b>.
594 * @param aCallback
595 * Specifies the callback object to be called.
596 *
597 * @see javax.media.opengl.GL#glBegin glBegin
598 * @see javax.media.opengl.GL#glEdgeFlag glEdgeFlag
599 * @see javax.media.opengl.GL#glVertex3f glVertex3f
600 * @see #gluNewTess gluNewTess
601 * @see #gluErrorString gluErrorString
602 * @see #gluTessVertex gluTessVertex
603 * @see #gluTessBeginPolygon gluTessBeginPolygon
604 * @see #gluTessBeginContour gluTessBeginContour
605 * @see #gluTessProperty gluTessProperty
606 * @see #gluTessNormal gluTessNormal
607 ****************************************************************************/
gluTessCallback(GLUtessellator tessellator, int which, GLUtessellatorCallback aCallback)608 public void gluTessCallback(GLUtessellator tessellator, int which, GLUtessellatorCallback aCallback) {
609 GLUtessellatorImpl tess = (GLUtessellatorImpl) tessellator;
610 tess.gluTessCallback(which, aCallback);
611 }
612
613 /*****************************************************************************
614 * <b>gluTessVertex</b> describes a vertex on a polygon that the program
615 * defines. Successive <b>gluTessVertex</b> calls describe a closed contour.
616 * For example, to describe a quadrilateral <b>gluTessVertex</b> should be
617 * called four times. <b>gluTessVertex</b> can only be called between
618 * {@link #gluTessBeginContour gluTessBeginContour} and
619 * {@link #gluTessBeginContour gluTessEndContour}.<P>
620 *
621 * <b>data</b> normally references to a structure containing the vertex
622 * location, as well as other per-vertex attributes such as color and normal.
623 * This reference is passed back to the user through the
624 * <b>GLU_TESS_VERTEX</b> or <b>GLU_TESS_VERTEX_DATA</b> callback after
625 * tessellation (see the {@link #gluTessCallback
626 * gluTessCallback} reference page).
627 *
628 * @param tessellator
629 * Specifies the tessellation object (created with
630 * {@link #gluNewTess gluNewTess}).
631 * @param coords
632 * Specifies the coordinates of the vertex.
633 * @param data
634 * Specifies an opaque reference passed back to the program with the
635 * vertex callback (as specified by
636 * {@link #gluTessCallback gluTessCallback}).
637 *
638 * @see #gluTessBeginPolygon gluTessBeginPolygon
639 * @see #gluNewTess gluNewTess
640 * @see #gluTessBeginContour gluTessBeginContour
641 * @see #gluTessCallback gluTessCallback
642 * @see #gluTessProperty gluTessProperty
643 * @see #gluTessNormal gluTessNormal
644 * @see #gluTessEndPolygon gluTessEndPolygon
645 ****************************************************************************/
gluTessVertex(GLUtessellator tessellator, double[] coords, int coords_offset, Object data)646 public void gluTessVertex(GLUtessellator tessellator, double[] coords, int coords_offset, Object data) {
647 GLUtessellatorImpl tess = (GLUtessellatorImpl) tessellator;
648 tess.gluTessVertex(coords, coords_offset, data);
649 }
650
651 /*****************************************************************************
652 * <b>gluTessBeginPolygon</b> and
653 * {@link #gluTessEndPolygon gluTessEndPolygon} delimit
654 * the definition of a convex, concave or self-intersecting polygon. Within
655 * each <b>gluTessBeginPolygon</b>/
656 * {@link #gluTessEndPolygon gluTessEndPolygon} pair,
657 * there must be one or more calls to
658 * {@link #gluTessBeginContour gluTessBeginContour}/
659 * {@link #gluTessEndContour gluTessEndContour}. Within
660 * each contour, there are zero or more calls to
661 * {@link #gluTessVertex gluTessVertex}. The vertices
662 * specify a closed contour (the last vertex of each contour is automatically
663 * linked to the first). See the {@link #gluTessVertex
664 * gluTessVertex}, {@link #gluTessBeginContour
665 * gluTessBeginContour}, and {@link #gluTessEndContour
666 * gluTessEndContour} reference pages for more details.<P>
667 *
668 * <b>data</b> is a reference to a user-defined data structure. If the
669 * appropriate callback(s) are specified (see
670 * {@link #gluTessCallback gluTessCallback}), then this
671 * reference is returned to the callback method(s). Thus, it is a convenient
672 * way to store per-polygon information.<P>
673 *
674 * Once {@link #gluTessEndPolygon gluTessEndPolygon} is
675 * called, the polygon is tessellated, and the resulting triangles are
676 * described through callbacks. See
677 * {@link #gluTessCallback gluTessCallback} for
678 * descriptions of the callback methods.
679 *
680 * @param tessellator
681 * Specifies the tessellation object (created with
682 * {@link #gluNewTess gluNewTess}).
683 * @param data
684 * Specifies a reference to user polygon data.
685 *
686 * @see #gluNewTess gluNewTess
687 * @see #gluTessBeginContour gluTessBeginContour
688 * @see #gluTessVertex gluTessVertex
689 * @see #gluTessCallback gluTessCallback
690 * @see #gluTessProperty gluTessProperty
691 * @see #gluTessNormal gluTessNormal
692 * @see #gluTessEndPolygon gluTessEndPolygon
693 ****************************************************************************/
gluTessBeginPolygon(GLUtessellator tessellator, Object data)694 public void gluTessBeginPolygon(GLUtessellator tessellator, Object data) {
695 GLUtessellatorImpl tess = (GLUtessellatorImpl) tessellator;
696 tess.gluTessBeginPolygon(data);
697 }
698
699 /*****************************************************************************
700 * <b>gluTessBeginContour</b> and
701 * {@link #gluTessEndContour gluTessEndContour} delimit
702 * the definition of a polygon contour. Within each
703 * <b>gluTessBeginContour</b>/
704 * {@link #gluTessEndContour gluTessEndContour} pair,
705 * there can be zero or more calls to
706 * {@link #gluTessVertex gluTessVertex}. The vertices
707 * specify a closed contour (the last vertex of each contour is automatically
708 * linked to the first). See the {@link #gluTessVertex
709 * gluTessVertex} reference page for more details. <b>gluTessBeginContour</b>
710 * can only be called between
711 * {@link #gluTessBeginPolygon gluTessBeginPolygon} and
712 * {@link #gluTessEndPolygon gluTessEndPolygon}.
713 *
714 * @param tessellator
715 * Specifies the tessellation object (created with
716 * {@link #gluNewTess gluNewTess}).
717 *
718 * @see #gluNewTess gluNewTess
719 * @see #gluTessBeginPolygon gluTessBeginPolygon
720 * @see #gluTessVertex gluTessVertex
721 * @see #gluTessCallback gluTessCallback
722 * @see #gluTessProperty gluTessProperty
723 * @see #gluTessNormal gluTessNormal
724 * @see #gluTessEndPolygon gluTessEndPolygon
725 ****************************************************************************/
gluTessBeginContour(GLUtessellator tessellator)726 public void gluTessBeginContour(GLUtessellator tessellator) {
727 GLUtessellatorImpl tess = (GLUtessellatorImpl) tessellator;
728 tess.gluTessBeginContour();
729 }
730
731 /*****************************************************************************
732 * <b>gluTessEndContour</b> and
733 * {@link #gluTessBeginContour gluTessBeginContour}
734 * delimit the definition of a polygon contour. Within each
735 * {@link #gluTessBeginContour gluTessBeginContour}/
736 * <b>gluTessEndContour</b> pair, there can be zero or more calls to
737 * {@link #gluTessVertex gluTessVertex}. The vertices
738 * specify a closed contour (the last vertex of each contour is automatically
739 * linked to the first). See the {@link #gluTessVertex
740 * gluTessVertex} reference page for more details.
741 * {@link #gluTessBeginContour gluTessBeginContour} can
742 * only be called between {@link #gluTessBeginPolygon
743 * gluTessBeginPolygon} and
744 * {@link #gluTessEndPolygon gluTessEndPolygon}.
745 *
746 * @param tessellator
747 * Specifies the tessellation object (created with
748 * {@link #gluNewTess gluNewTess}).
749 *
750 * @see #gluNewTess gluNewTess
751 * @see #gluTessBeginPolygon gluTessBeginPolygon
752 * @see #gluTessVertex gluTessVertex
753 * @see #gluTessCallback gluTessCallback
754 * @see #gluTessProperty gluTessProperty
755 * @see #gluTessNormal gluTessNormal
756 * @see #gluTessEndPolygon gluTessEndPolygon
757 ****************************************************************************/
gluTessEndContour(GLUtessellator tessellator)758 public void gluTessEndContour(GLUtessellator tessellator) {
759 GLUtessellatorImpl tess = (GLUtessellatorImpl) tessellator;
760 tess.gluTessEndContour();
761 }
762
763 /*****************************************************************************
764 * <b>gluTessEndPolygon</b> and
765 * {@link #gluTessBeginPolygon gluTessBeginPolygon}
766 * delimit the definition of a convex, concave or self-intersecting polygon.
767 * Within each {@link #gluTessBeginPolygon
768 * gluTessBeginPolygon}/<b>gluTessEndPolygon</b> pair, there must be one or
769 * more calls to {@link #gluTessBeginContour
770 * gluTessBeginContour}/{@link #gluTessEndContour
771 * gluTessEndContour}. Within each contour, there are zero or more calls to
772 * {@link #gluTessVertex gluTessVertex}. The vertices
773 * specify a closed contour (the last vertex of each contour is automatically
774 * linked to the first). See the {@link #gluTessVertex
775 * gluTessVertex}, {@link #gluTessBeginContour
776 * gluTessBeginContour} and {@link #gluTessEndContour
777 * gluTessEndContour} reference pages for more details.<P>
778 *
779 * Once <b>gluTessEndPolygon</b> is called, the polygon is tessellated, and
780 * the resulting triangles are described through callbacks. See
781 * {@link #gluTessCallback gluTessCallback} for
782 * descriptions of the callback functions.
783 *
784 * @param tessellator
785 * Specifies the tessellation object (created with
786 * {@link #gluNewTess gluNewTess}).
787 *
788 * @see #gluNewTess gluNewTess
789 * @see #gluTessBeginContour gluTessBeginContour
790 * @see #gluTessVertex gluTessVertex
791 * @see #gluTessCallback gluTessCallback
792 * @see #gluTessProperty gluTessProperty
793 * @see #gluTessNormal gluTessNormal
794 * @see #gluTessBeginPolygon gluTessBeginPolygon
795 ****************************************************************************/
gluTessEndPolygon(GLUtessellator tessellator)796 public void gluTessEndPolygon(GLUtessellator tessellator) {
797 GLUtessellatorImpl tess = (GLUtessellatorImpl) tessellator;
798 tess.gluTessEndPolygon();
799 }
800
801 /*****************************************************************************
802
803 * <b>gluBeginPolygon</b> and {@link #gluEndPolygon gluEndPolygon}
804 * delimit the definition of a nonconvex polygon. To define such a
805 * polygon, first call <b>gluBeginPolygon</b>. Then define the
806 * contours of the polygon by calling {@link #gluTessVertex
807 * gluTessVertex} for each vertex and {@link #gluNextContour
808 * gluNextContour} to start each new contour. Finally, call {@link
809 * #gluEndPolygon gluEndPolygon} to signal the end of the
810 * definition. See the {@link #gluTessVertex gluTessVertex} and {@link
811 * #gluNextContour gluNextContour} reference pages for more
812 * details.<P>
813
814 *
815 * Once {@link #gluEndPolygon gluEndPolygon} is called,
816 * the polygon is tessellated, and the resulting triangles are described
817 * through callbacks. See {@link #gluTessCallback
818 * gluTessCallback} for descriptions of the callback methods.
819 *
820 * @param tessellator
821 * Specifies the tessellation object (created with
822 * {@link #gluNewTess gluNewTess}).
823 *
824 * @see #gluNewTess gluNewTess
825 * @see #gluNextContour gluNextContour
826 * @see #gluTessCallback gluTessCallback
827 * @see #gluTessVertex gluTessVertex
828 * @see #gluTessBeginPolygon gluTessBeginPolygon
829 * @see #gluTessBeginContour gluTessBeginContour
830 ****************************************************************************/
gluBeginPolygon(GLUtessellator tessellator)831 public void gluBeginPolygon(GLUtessellator tessellator) {
832 GLUtessellatorImpl tess = (GLUtessellatorImpl) tessellator;
833 tess.gluBeginPolygon();
834 }
835
836 /*****************************************************************************
837 * <b>gluNextContour</b> is used to describe polygons with multiple
838 * contours. After you describe the first contour through a series of
839 * {@link #gluTessVertex gluTessVertex} calls, a
840 * <b>gluNextContour</b> call indicates that the previous contour is complete
841 * and that the next contour is about to begin. Perform another series of
842 * {@link #gluTessVertex gluTessVertex} calls to
843 * describe the new contour. Repeat this process until all contours have been
844 * described.<P>
845 *
846 * The type parameter defines what type of contour follows. The following
847 * values are valid. <P>
848 *
849 * <b>GLU_EXTERIOR</b>
850 * <UL>
851 * An exterior contour defines an exterior boundary of the polygon.
852 * </UL>
853 * <b>GLU_INTERIOR</b>
854 * <UL>
855 * An interior contour defines an interior boundary of the polygon (such as
856 * a hole).
857 * </UL>
858 * <b>GLU_UNKNOWN</b>
859 * <UL>
860 * An unknown contour is analyzed by the library to determine whether it is
861 * interior or exterior.
862 * </UL>
863 * <b>GLU_CCW, GLU_CW</b>
864 * <UL>
865 * The first <b>GLU_CCW</b> or <b>GLU_CW</b> contour defined is considered
866 * to be exterior. All other contours are considered to be exterior if they
867 * are oriented in the same direction (clockwise or counterclockwise) as the
868 * first contour, and interior if they are not. If one contour is of type
869 * <b>GLU_CCW</b> or <b>GLU_CW</b>, then all contours must be of the same
870 * type (if they are not, then all <b>GLU_CCW</b> and <b>GLU_CW</b> contours
871 * will be changed to <b>GLU_UNKNOWN</b>). Note that there is no
872 * real difference between the <b>GLU_CCW</b> and <b>GLU_CW</b> contour
873 * types.
874 * </UL><P>
875 *
876 * To define the type of the first contour, you can call <b>gluNextContour</b>
877 * before describing the first contour. If you do not call
878 * <b>gluNextContour</b> before the first contour, the first contour is marked
879 * <b>GLU_EXTERIOR</b>.<P>
880 *
881 * <UL>
882 * <b>Note:</b> The <b>gluNextContour</b> function is obsolete and is
883 * provided for backward compatibility only. The <b>gluNextContour</b>
884 * function is mapped to {@link #gluTessEndContour
885 * gluTessEndContour} followed by
886 * {@link #gluTessBeginContour gluTessBeginContour}.
887 * </UL>
888 *
889 * @param tessellator
890 * Specifies the tessellation object (created with
891 * {@link #gluNewTess gluNewTess}).
892 * @param type
893 * The type of the contour being defined.
894 *
895 * @see #gluNewTess gluNewTess
896 * @see #gluTessBeginContour gluTessBeginContour
897 * @see #gluTessBeginPolygon gluTessBeginPolygon
898 * @see #gluTessCallback gluTessCallback
899 * @see #gluTessEndContour gluTessEndContour
900 * @see #gluTessVertex gluTessVertex
901 ****************************************************************************/
gluNextContour(GLUtessellator tessellator, int type)902 public void gluNextContour(GLUtessellator tessellator, int type) {
903 GLUtessellatorImpl tess = (GLUtessellatorImpl) tessellator;
904 tess.gluNextContour(type);
905 }
906
907 /*****************************************************************************
908 * <b>gluEndPolygon</b> and {@link #gluBeginPolygon
909 * gluBeginPolygon} delimit the definition of a nonconvex polygon. To define
910 * such a polygon, first call {@link #gluBeginPolygon
911 * gluBeginPolygon}. Then define the contours of the polygon by calling
912 * {@link #gluTessVertex gluTessVertex} for each vertex
913 * and {@link #gluNextContour gluNextContour} to start
914 * each new contour. Finally, call <b>gluEndPolygon</b> to signal the end of
915 * the definition. See the {@link #gluTessVertex
916 * gluTessVertex} and {@link #gluNextContour
917 * gluNextContour} reference pages for more details.<P>
918 *
919 * Once <b>gluEndPolygon</b> is called, the polygon is tessellated, and the
920 * resulting triangles are described through callbacks. See
921 * {@link #gluTessCallback gluTessCallback} for
922 * descriptions of the callback methods.
923 *
924 * @param tessellator
925 * Specifies the tessellation object (created with
926 * {@link #gluNewTess gluNewTess}).
927 *
928 * @see #gluNewTess gluNewTess
929 * @see #gluNextContour gluNextContour
930 * @see #gluTessCallback gluTessCallback
931 * @see #gluTessVertex gluTessVertex
932 * @see #gluTessBeginPolygon gluTessBeginPolygon
933 * @see #gluTessBeginContour gluTessBeginContour
934 ****************************************************************************/
gluEndPolygon(GLUtessellator tessellator)935 public void gluEndPolygon(GLUtessellator tessellator) {
936 GLUtessellatorImpl tess = (GLUtessellatorImpl) tessellator;
937 tess.gluEndPolygon();
938 }
939
940 //----------------------------------------------------------------------
941 // Quadric functionality
942 //
943
944 /** Interface to C language function: <br> <code> void gluCylinder(GLUquadric * quad, GLdouble base, GLdouble top, GLdouble height, GLint slices, GLint stacks); </code> */
gluCylinder(GLUquadric quad, double base, double top, double height, int slices, int stacks)945 public void gluCylinder(GLUquadric quad, double base, double top, double height, int slices, int stacks) {
946 ((GLUquadricImpl) quad).drawCylinder(getCurrentGL(), (float) base, (float) top, (float) height, slices, stacks);
947 }
948
949 /** Interface to C language function: <br> <code> void gluDeleteQuadric(GLUquadric * quad); </code> */
gluDeleteQuadric(GLUquadric quad)950 public void gluDeleteQuadric(GLUquadric quad) {
951 }
952
953 /** Interface to C language function: <br> <code> void gluDisk(GLUquadric * quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops); </code> */
gluDisk(GLUquadric quad, double inner, double outer, int slices, int loops)954 public void gluDisk(GLUquadric quad, double inner, double outer, int slices, int loops) {
955 ((GLUquadricImpl) quad).drawDisk(getCurrentGL(), (float) inner, (float) outer, slices, loops);
956 }
957
958 /** Interface to C language function: <br> <code> GLUquadric * gluNewQuadric(void); </code> */
gluNewQuadric()959 public GLUquadric gluNewQuadric() {
960 return new GLUquadricImpl();
961 }
962
963 /** Interface to C language function: <br> <code> void gluPartialDisk(GLUquadric * quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops, GLdouble start, GLdouble sweep); </code> */
gluPartialDisk(GLUquadric quad, double inner, double outer, int slices, int loops, double start, double sweep)964 public void gluPartialDisk(GLUquadric quad, double inner, double outer, int slices, int loops, double start, double sweep) {
965 ((GLUquadricImpl) quad).drawPartialDisk(getCurrentGL(), (float) inner, (float) outer, slices, loops, (float) start, (float) sweep);
966 }
967
968 /** Interface to C language function: <br> <code> void gluQuadricDrawStyle(GLUquadric * quad, GLenum draw); </code> */
gluQuadricDrawStyle(GLUquadric quad, int draw)969 public void gluQuadricDrawStyle(GLUquadric quad, int draw) {
970 ((GLUquadricImpl) quad).setDrawStyle(draw);
971 }
972
973 /** Interface to C language function: <br> <code> void gluQuadricNormals(GLUquadric * quad, GLenum normal); </code> */
gluQuadricNormals(GLUquadric quad, int normal)974 public void gluQuadricNormals(GLUquadric quad, int normal) {
975 ((GLUquadricImpl) quad).setNormals(normal);
976 }
977
978 /** Interface to C language function: <br> <code> void gluQuadricOrientation(GLUquadric * quad, GLenum orientation); </code> */
gluQuadricOrientation(GLUquadric quad, int orientation)979 public void gluQuadricOrientation(GLUquadric quad, int orientation) {
980 ((GLUquadricImpl) quad).setOrientation(orientation);
981 }
982
983 /** Interface to C language function: <br> <code> void gluQuadricTexture(GLUquadric * quad, GLboolean texture); </code> */
gluQuadricTexture(GLUquadric quad, boolean texture)984 public void gluQuadricTexture(GLUquadric quad, boolean texture) {
985 ((GLUquadricImpl) quad).setTextureFlag(texture);
986 }
987
988 /** Interface to C language function: <br> <code> void gluSphere(GLUquadric * quad, GLdouble radius, GLint slices, GLint stacks); </code> */
gluSphere(GLUquadric quad, double radius, int slices, int stacks)989 public void gluSphere(GLUquadric quad, double radius, int slices, int stacks) {
990 ((GLUquadricImpl) quad).drawSphere(getCurrentGL(), (float) radius, slices, stacks);
991 }
992
993 //----------------------------------------------------------------------
994 // Projection routines
995 //
996
997 private Project project;
998
gluOrtho2D(double left, double right, double bottom, double top)999 public void gluOrtho2D(double left, double right, double bottom, double top) {
1000 project.gluOrtho2D(getCurrentGL(), left, right, bottom, top);
1001 }
1002
gluPerspective(double fovy, double aspect, double zNear, double zFar)1003 public void gluPerspective(double fovy, double aspect, double zNear, double zFar) {
1004 project.gluPerspective(getCurrentGL(), fovy, aspect, zNear, zFar);
1005 }
1006
gluLookAt(double eyeX, double eyeY, double eyeZ, double centerX, double centerY, double centerZ, double upX, double upY, double upZ)1007 public void gluLookAt(double eyeX, double eyeY, double eyeZ, double centerX, double centerY, double centerZ, double upX, double upY, double upZ) {
1008 project.gluLookAt(getCurrentGL(), eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ);
1009 }
1010
1011 /** Interface to C language function: <br> <code> GLint gluProject(GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble * model, const GLdouble * proj, const GLint * view, GLdouble * winX, GLdouble * winY, GLdouble * winZ); </code>
1012 * <P> Accepts the outgoing window coordinates as a single array.
1013 */
gluProject(double objX, double objY, double objZ, double[] model, int model_offset, double[] proj, int proj_offset, int[] view, int view_offset, double[] winPos, int winPos_offset)1014 public boolean gluProject(double objX, double objY, double objZ, double[] model, int model_offset, double[] proj, int proj_offset, int[] view, int view_offset, double[] winPos, int winPos_offset) {
1015 return project.gluProject(objX, objY, objZ, model, model_offset, proj, proj_offset, view, view_offset, winPos, winPos_offset);
1016 }
1017
1018 /** Interface to C language function: <br> <code> GLint gluProject(GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble * model, const GLdouble * proj, const GLint * view, GLdouble * winX, GLdouble * winY, GLdouble * winZ); </code>
1019 * <P> Accepts the outgoing window coordinates as a single buffer.
1020 */
gluProject(double objX, double objY, double objZ, java.nio.DoubleBuffer model, java.nio.DoubleBuffer proj, java.nio.IntBuffer view, java.nio.DoubleBuffer winPos)1021 public boolean gluProject(double objX, double objY, double objZ, java.nio.DoubleBuffer model, java.nio.DoubleBuffer proj, java.nio.IntBuffer view, java.nio.DoubleBuffer winPos) {
1022 return project.gluProject(objX, objY, objZ, model, proj, view, winPos);
1023 }
1024
1025 /** Interface to C language function: <br> <code> GLint gluUnProject(GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble * model, const GLdouble * proj, const GLint * view, GLdouble * objX, GLdouble * objY, GLdouble * objZ); </code>
1026 * <P> Accepts the outgoing object coordinates (a 3-vector) as a single array.
1027 */
gluUnProject(double winX, double winY, double winZ, double[] model, int model_offset, double[] proj, int proj_offset, int[] view, int view_offset, double[] objPos, int objPos_offset)1028 public boolean gluUnProject(double winX, double winY, double winZ, double[] model, int model_offset, double[] proj, int proj_offset, int[] view, int view_offset, double[] objPos, int objPos_offset) {
1029 return project.gluUnProject(winX, winY, winZ, model, model_offset, proj, proj_offset, view, view_offset, objPos, objPos_offset);
1030 }
1031
1032 /** Interface to C language function: <br> <code> GLint gluUnProject(GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble * model, const GLdouble * proj, const GLint * view, GLdouble * objX, GLdouble * objY, GLdouble * objZ); </code>
1033 * <P> Accepts the outgoing object coordinates (a 3-vector) as a single buffer.
1034 */
gluUnProject(double winX, double winY, double winZ, java.nio.DoubleBuffer model, java.nio.DoubleBuffer proj, java.nio.IntBuffer view, java.nio.DoubleBuffer objPos)1035 public boolean gluUnProject(double winX, double winY, double winZ, java.nio.DoubleBuffer model, java.nio.DoubleBuffer proj, java.nio.IntBuffer view, java.nio.DoubleBuffer objPos) {
1036 return project.gluUnProject(winX, winY, winZ, model, proj, view, objPos);
1037 }
1038
1039 /** Interface to C language function: <br> <code> 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); </code>
1040 * <P> Accepts the outgoing object coordinates (a 4-vector) as a single array.
1041 */
gluUnProject4(double winX, double winY, double winZ, double clipW, double[] model, int model_offset, double[] proj, int proj_offset, int[] view, int view_offset, double nearVal, double farVal, double[] objPos, int objPos_offset)1042 public boolean gluUnProject4(double winX, double winY, double winZ, double clipW, double[] model, int model_offset, double[] proj, int proj_offset, int[] view, int view_offset, double nearVal, double farVal, double[] objPos, int objPos_offset) {
1043 return project.gluUnProject4(winX, winY, winZ, clipW, model, model_offset, proj, proj_offset, view, view_offset, nearVal, farVal, objPos, objPos_offset);
1044 }
1045
1046 /** Interface to C language function: <br> <code> 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); </code>
1047 * <P> Accepts the outgoing object coordinates (a 4-vector) as a single buffer.
1048 */
gluUnProject4(double winX, double winY, double winZ, double clipW, java.nio.DoubleBuffer model, java.nio.DoubleBuffer proj, java.nio.IntBuffer view, double nearVal, double farVal, java.nio.DoubleBuffer objPos)1049 public boolean gluUnProject4(double winX, double winY, double winZ, double clipW, java.nio.DoubleBuffer model, java.nio.DoubleBuffer proj, java.nio.IntBuffer view, double nearVal, double farVal, java.nio.DoubleBuffer objPos) {
1050 return project.gluUnProject4(winX, winY, winZ, clipW, model, proj, view, nearVal, farVal, objPos);
1051 }
1052
gluPickMatrix(double x, double y, double delX, double delY, int[] viewport, int viewport_offset)1053 public void gluPickMatrix(double x, double y, double delX, double delY, int[] viewport, int viewport_offset) {
1054 project.gluPickMatrix(getCurrentGL(), x, y, delX, delY, viewport, viewport_offset);
1055 }
1056
gluPickMatrix(double x, double y, double delX, double delY, java.nio.IntBuffer viewport)1057 public void gluPickMatrix(double x, double y, double delX, double delY, java.nio.IntBuffer viewport) {
1058 project.gluPickMatrix(getCurrentGL(), x, y, delX, delY, viewport);
1059 }
1060
1061 //----------------------------------------------------------------------
1062 // Mipmap and image scaling functionality
1063
1064
1065 // Boolean
1066 public static final int GLU_FALSE = 0;
1067 public static final int GLU_TRUE = 1;
1068
1069 // String Name
1070 public static final int GLU_VERSION = 100800;
1071 public static final int GLU_EXTENSIONS = 100801;
1072
1073 // Extensions
1074 public static final String versionString = "1.3";
1075 public static final String extensionString = "GLU_EXT_nurbs_tessellator " +
1076 "GLU_EXT_object_space_tess ";
1077
1078 // ErrorCode
1079 public static final int GLU_INVALID_ENUM = 100900;
1080 public static final int GLU_INVALID_VALUE = 100901;
1081 public static final int GLU_OUT_OF_MEMORY = 100902;
1082 public static final int GLU_INVALID_OPERATION = 100904;
1083
1084 // NurbsDisplay
1085 // GLU_FILL
1086 //public static final int GLU_OUTLINE_POLYGON = 100240;
1087 //public static final int GLU_OUTLINE_PATCH = 100241;
1088
1089 // NurbsCallback
1090 //public static final int GLU_NURBS_ERROR = 100103;
1091 public static final int GLU_ERROR = 100103;
1092 //public static final int GLU_NURBS_BEGIN = 100164;
1093 //public static final int GLU_NURBS_BEGIN_EXT = 100164;
1094 //public static final int GLU_NURBS_VERTEX = 100165;
1095 //public static final int GLU_NURBS_VERTEX_EXT = 100165;
1096 //public static final int GLU_NURBS_NORMAL = 100166;
1097 //public static final int GLU_NURBS_NORMAL_EXT = 100166;
1098 //public static final int GLU_NURBS_COLOR = 100167;
1099 //public static final int GLU_NURBS_COLOR_EXT = 100167;
1100 //public static final int GLU_NURBS_TEXTURE_COORD = 100168;
1101 //public static final int GLU_NURBS_TEX_COORD_EXT = 100168;
1102 //public static final int GLU_NURBS_END = 100169;
1103 //public static final int GLU_NURBS_END_EXT = 100169;
1104 //public static final int GLU_NURBS_BEGIN_DATA = 100170;
1105 //public static final int GLU_NURBS_BEGIN_DATA_EXT = 100170;
1106 //public static final int GLU_NURBS_VERTEX_DATA = 100171;
1107 //public static final int GLU_NURBS_VERTEX_DATA_EXT = 100171;
1108 //public static final int GLU_NURBS_NORMAL_DATA = 100172;
1109 //public static final int GLU_NURBS_NORMAL_DATA_EXT = 100172;
1110 //public static final int GLU_NURBS_COLOR_DATA = 100173;
1111 //public static final int GLU_NURBS_COLOR_DATA_EXT = 100173;
1112 //public static final int GLU_NURBS_TEXTURE_COORD_DATA = 100174;
1113 //public static final int GLU_NURBS_TEX_COORD_DATA_EXT = 100174;
1114 //public static final int GLU_NURBS_END_DATA = 100175;
1115 //public static final int GLU_NURBS_END_DATA_EXT = 100175;
1116
1117 // NurbsError
1118 //public static final int GLU_NURBS_ERROR1 = 100251;
1119 //public static final int GLU_NURBS_ERROR2 = 100252;
1120 //public static final int GLU_NURBS_ERROR3 = 100253;
1121 //public static final int GLU_NURBS_ERROR4 = 100254;
1122 //public static final int GLU_NURBS_ERROR5 = 100255;
1123 //public static final int GLU_NURBS_ERROR6 = 100256;
1124 //public static final int GLU_NURBS_ERROR7 = 100257;
1125 //public static final int GLU_NURBS_ERROR8 = 100258;
1126 //public static final int GLU_NURBS_ERROR9 = 100259;
1127 //public static final int GLU_NURBS_ERROR10 = 100260;
1128 //public static final int GLU_NURBS_ERROR11 = 100261;
1129 //public static final int GLU_NURBS_ERROR12 = 100262;
1130 //public static final int GLU_NURBS_ERROR13 = 100263;
1131 //public static final int GLU_NURBS_ERROR14 = 100264;
1132 //public static final int GLU_NURBS_ERROR15 = 100265;
1133 //public static final int GLU_NURBS_ERROR16 = 100266;
1134 //public static final int GLU_NURBS_ERROR17 = 100267;
1135 //public static final int GLU_NURBS_ERROR18 = 100268;
1136 //public static final int GLU_NURBS_ERROR19 = 100269;
1137 //public static final int GLU_NURBS_ERROR20 = 100270;
1138 //public static final int GLU_NURBS_ERROR21 = 100271;
1139 //public static final int GLU_NURBS_ERROR22 = 100272;
1140 //public static final int GLU_NURBS_ERROR23 = 100273;
1141 //public static final int GLU_NURBS_ERROR24 = 100274;
1142 //public static final int GLU_NURBS_ERROR25 = 100275;
1143 //public static final int GLU_NURBS_ERROR26 = 100276;
1144 //public static final int GLU_NURBS_ERROR27 = 100277;
1145 //public static final int GLU_NURBS_ERROR28 = 100278;
1146 //public static final int GLU_NURBS_ERROR29 = 100279;
1147 //public static final int GLU_NURBS_ERROR30 = 100280;
1148 //public static final int GLU_NURBS_ERROR31 = 100281;
1149 //public static final int GLU_NURBS_ERROR32 = 100282;
1150 //public static final int GLU_NURBS_ERROR33 = 100283;
1151 //public static final int GLU_NURBS_ERROR34 = 100284;
1152 //public static final int GLU_NURBS_ERROR35 = 100285;
1153 //public static final int GLU_NURBS_ERROR36 = 100286;
1154 //public static final int GLU_NURBS_ERROR37 = 100287;
1155
1156 // NurbsProperty
1157 //public static final int GLU_AUTO_LOAD_MATRIX = 100200;
1158 //public static final int GLU_CULLING = 100201;
1159 //public static final int GLU_SAMPLING_TOLERANCE = 100203;
1160 //public static final int GLU_DISPLAY_MODE = 100204;
1161 //public static final int GLU_PARAMETRIC_TOLERANCE = 100202;
1162 //public static final int GLU_SAMPLING_METHOD = 100205;
1163 //public static final int GLU_U_STEP = 100206;
1164 //public static final int GLU_V_STEP = 100207;
1165 //public static final int GLU_NURBS_MODE = 100160;
1166 //public static final int GLU_NURBS_MODE_EXT = 100160;
1167 //public static final int GLU_NURBS_TESSELLATOR = 100161;
1168 //public static final int GLU_NURBS_TESSELLATOR_EXT = 100161;
1169 //public static final int GLU_NURBS_RENDERER = 100162;
1170 //public static final int GLU_NURBS_RENDERER_EXT = 100162;
1171
1172 // NurbsSampling
1173 //public static final int GLU_OBJECT_PARAMETRIC_ERROR = 100208;
1174 //public static final int GLU_OBJECT_PARAMETRIC_ERROR_EXT = 100208;
1175 //public static final int GLU_OBJECT_PATH_LENGTH = 100209;
1176 //public static final int GLU_OBJECT_PATH_LENGTH_EXT = 100209;
1177 //public static final int GLU_PATH_LENGTH = 100215;
1178 //public static final int GLU_PARAMETRIC_ERROR = 100216;
1179 //public static final int GLU_DOMAIN_DISTANCE = 100217;
1180
1181 // NurbsTrim
1182 //public static final int GLU_MAP1_TRIM_2 = 100210;
1183 //public static final int GLU_MAP1_TRIM_3 = 100211;
1184
1185 // QuadricDrawStyle
1186 public static final int GLU_POINT = 100010;
1187 public static final int GLU_LINE = 100011;
1188 public static final int GLU_FILL = 100012;
1189 public static final int GLU_SILHOUETTE = 100013;
1190
1191 // QuadricCallback
1192 // GLU_ERROR
1193
1194 // QuadricNormal
1195 public static final int GLU_SMOOTH = 100000;
1196 public static final int GLU_FLAT = 100001;
1197 public static final int GLU_NONE = 100002;
1198
1199 // QuadricOrientation
1200 public static final int GLU_OUTSIDE = 100020;
1201 public static final int GLU_INSIDE = 100021;
1202
1203 // TessCallback
1204 public static final int GLU_TESS_BEGIN = 100100;
1205 public static final int GLU_BEGIN = 100100;
1206 public static final int GLU_TESS_VERTEX = 100101;
1207 public static final int GLU_VERTEX = 100101;
1208 public static final int GLU_TESS_END = 100102;
1209 public static final int GLU_END = 100102;
1210 public static final int GLU_TESS_ERROR = 100103;
1211 public static final int GLU_TESS_EDGE_FLAG = 100104;
1212 public static final int GLU_EDGE_FLAG = 100104;
1213 public static final int GLU_TESS_COMBINE = 100105;
1214 public static final int GLU_TESS_BEGIN_DATA = 100106;
1215 public static final int GLU_TESS_VERTEX_DATA = 100107;
1216 public static final int GLU_TESS_END_DATA = 100108;
1217 public static final int GLU_TESS_ERROR_DATA = 100109;
1218 public static final int GLU_TESS_EDGE_FLAG_DATA = 100110;
1219 public static final int GLU_TESS_COMBINE_DATA = 100111;
1220
1221 // TessContour
1222 public static final int GLU_CW = 100120;
1223 public static final int GLU_CCW = 100121;
1224 public static final int GLU_INTERIOR = 100122;
1225 public static final int GLU_EXTERIOR = 100123;
1226 public static final int GLU_UNKNOWN = 100124;
1227
1228 // TessProperty
1229 public static final int GLU_TESS_WINDING_RULE = 100140;
1230 public static final int GLU_TESS_BOUNDARY_ONLY = 100141;
1231 public static final int GLU_TESS_TOLERANCE = 100142;
1232
1233 // TessError
1234 public static final int GLU_TESS_ERROR1 = 100151;
1235 public static final int GLU_TESS_ERROR2 = 100152;
1236 public static final int GLU_TESS_ERROR3 = 100153;
1237 public static final int GLU_TESS_ERROR4 = 100154;
1238 public static final int GLU_TESS_ERROR5 = 100155;
1239 public static final int GLU_TESS_ERROR6 = 100156;
1240 public static final int GLU_TESS_ERROR7 = 100157;
1241 public static final int GLU_TESS_ERROR8 = 100158;
1242 public static final int GLU_TESS_MISSING_BEGIN_POLYGON = 100151;
1243 public static final int GLU_TESS_MISSING_BEGIN_CONTOUR = 100152;
1244 public static final int GLU_TESS_MISSING_END_POLYGON = 100153;
1245 public static final int GLU_TESS_MISSING_END_CONTOUR = 100154;
1246 public static final int GLU_TESS_COORD_TOO_LARGE = 100155;
1247 public static final int GLU_TESS_NEED_COMBINE_CALLBACK = 100156;
1248
1249 // TessWinding
1250 public static final int GLU_TESS_WINDING_ODD = 100130;
1251 public static final int GLU_TESS_WINDING_NONZERO = 100131;
1252 public static final int GLU_TESS_WINDING_POSITIVE = 100132;
1253 public static final int GLU_TESS_WINDING_NEGATIVE = 100133;
1254 public static final int GLU_TESS_WINDING_ABS_GEQ_TWO = 100134;
1255 public static final double GLU_TESS_MAX_COORD = 1.0e150;
1256
copyToByteBuffer(java.nio.Buffer buf)1257 private java.nio.ByteBuffer copyToByteBuffer(java.nio.Buffer buf) {
1258 if (buf instanceof java.nio.ByteBuffer) {
1259 if (buf.position() == 0) {
1260 return (java.nio.ByteBuffer) buf;
1261 }
1262 return BufferUtil.copyByteBuffer((java.nio.ByteBuffer) buf);
1263 } else if (buf instanceof java.nio.ShortBuffer) {
1264 return BufferUtil.copyShortBufferAsByteBuffer((java.nio.ShortBuffer) buf);
1265 } else if (buf instanceof java.nio.IntBuffer) {
1266 return BufferUtil.copyIntBufferAsByteBuffer((java.nio.IntBuffer) buf);
1267 } else if (buf instanceof java.nio.FloatBuffer) {
1268 return BufferUtil.copyFloatBufferAsByteBuffer((java.nio.FloatBuffer) buf);
1269 } else {
1270 throw new IllegalArgumentException("Unsupported buffer type (must be one of byte, short, int, or float)");
1271 }
1272 }
1273
gluScaleImageJava( int format, int widthin, int heightin, int typein, java.nio.Buffer datain, int widthout, int heightout, int typeout, java.nio.Buffer dataout )1274 private int gluScaleImageJava( int format, int widthin, int heightin,
1275 int typein, java.nio.Buffer datain, int widthout, int heightout,
1276 int typeout, java.nio.Buffer dataout ) {
1277 java.nio.ByteBuffer in = null;
1278 java.nio.ByteBuffer out = null;
1279 in = copyToByteBuffer(datain);
1280 if( dataout instanceof java.nio.ByteBuffer ) {
1281 out = (java.nio.ByteBuffer)dataout;
1282 } else if( dataout instanceof java.nio.ShortBuffer ) {
1283 out = BufferUtil.newByteBuffer(dataout.remaining() * BufferUtil.SIZEOF_SHORT);
1284 } else if ( dataout instanceof java.nio.IntBuffer ) {
1285 out = BufferUtil.newByteBuffer(dataout.remaining() * BufferUtil.SIZEOF_INT);
1286 } else if ( dataout instanceof java.nio.FloatBuffer ) {
1287 out = BufferUtil.newByteBuffer(dataout.remaining() * BufferUtil.SIZEOF_FLOAT);
1288 } else {
1289 throw new IllegalArgumentException("Unsupported destination buffer type (must be byte, short, int, or float)");
1290 }
1291 int errno = Mipmap.gluScaleImage( getCurrentGL(), format, widthin, heightin, typein, in,
1292 widthout, heightout, typeout, out );
1293 if( errno == 0 ) {
1294 out.rewind();
1295 if (out != dataout) {
1296 if( dataout instanceof java.nio.ShortBuffer ) {
1297 ((java.nio.ShortBuffer) dataout).put(out.asShortBuffer());
1298 } else if( dataout instanceof java.nio.IntBuffer ) {
1299 ((java.nio.IntBuffer) dataout).put(out.asIntBuffer());
1300 } else if( dataout instanceof java.nio.FloatBuffer ) {
1301 ((java.nio.FloatBuffer) dataout).put(out.asFloatBuffer());
1302 } else {
1303 throw new RuntimeException("Should not reach here");
1304 }
1305 }
1306 }
1307 return( errno );
1308 }
1309
1310
gluBuild1DMipmapLevelsJava( int target, int internalFormat, int width, int format, int type, int userLevel, int baseLevel, int maxLevel, java.nio.Buffer data )1311 private int gluBuild1DMipmapLevelsJava( int target, int internalFormat, int width,
1312 int format, int type, int userLevel, int baseLevel, int maxLevel,
1313 java.nio.Buffer data ) {
1314 java.nio.ByteBuffer buffer = copyToByteBuffer(data);
1315 return( Mipmap.gluBuild1DMipmapLevels( getCurrentGL(), target, internalFormat, width,
1316 format, type, userLevel, baseLevel, maxLevel, buffer ) );
1317 }
1318
1319
gluBuild1DMipmapsJava( int target, int internalFormat, int width, int format, int type, java.nio.Buffer data )1320 private int gluBuild1DMipmapsJava( int target, int internalFormat, int width,
1321 int format, int type, java.nio.Buffer data ) {
1322 java.nio.ByteBuffer buffer = copyToByteBuffer(data);
1323 return( Mipmap.gluBuild1DMipmaps( getCurrentGL(), target, internalFormat, width, format,
1324 type, buffer ) );
1325 }
1326
1327
gluBuild2DMipmapLevelsJava( int target, int internalFormat, int width, int height, int format, int type, int userLevel, int baseLevel, int maxLevel, java.nio.Buffer data )1328 private int gluBuild2DMipmapLevelsJava( int target, int internalFormat, int width,
1329 int height, int format, int type, int userLevel, int baseLevel,
1330 int maxLevel, java.nio.Buffer data ) {
1331 // While the code below handles other data types, it doesn't handle non-ByteBuffers
1332 data = copyToByteBuffer(data);
1333 return( Mipmap.gluBuild2DMipmapLevels( getCurrentGL(), target, internalFormat, width,
1334 height, format, type, userLevel, baseLevel, maxLevel, data ) );
1335 }
1336
gluBuild2DMipmapsJava( int target, int internalFormat, int width, int height, int format, int type, java.nio.Buffer data )1337 private int gluBuild2DMipmapsJava( int target, int internalFormat, int width,
1338 int height, int format, int type, java.nio.Buffer data ) {
1339 // While the code below handles other data types, it doesn't handle non-ByteBuffers
1340 data = copyToByteBuffer(data);
1341 return( Mipmap.gluBuild2DMipmaps( getCurrentGL(), target, internalFormat, width, height,
1342 format, type, data) );
1343 }
1344
gluBuild3DMipmapLevelsJava( int target, int internalFormat, int width, int height, int depth, int format, int type, int userLevel, int baseLevel, int maxLevel, java.nio.Buffer data)1345 private int gluBuild3DMipmapLevelsJava( int target, int internalFormat, int width,
1346 int height, int depth, int format, int type, int userLevel, int baseLevel,
1347 int maxLevel, java.nio.Buffer data) {
1348 java.nio.ByteBuffer buffer = copyToByteBuffer(data);
1349 return( Mipmap.gluBuild3DMipmapLevels( getCurrentGL(), target, internalFormat, width,
1350 height, depth, format, type, userLevel, baseLevel, maxLevel, buffer) );
1351 }
1352
gluBuild3DMipmapsJava( int target, int internalFormat, int width, int height, int depth, int format, int type, java.nio.Buffer data )1353 private int gluBuild3DMipmapsJava( int target, int internalFormat, int width,
1354 int height, int depth, int format, int type, java.nio.Buffer data ) {
1355 java.nio.ByteBuffer buffer = copyToByteBuffer(data);
1356 return( Mipmap.gluBuild3DMipmaps( getCurrentGL(), target, internalFormat, width, height,
1357 depth, format, type, buffer ) );
1358 }
1359
1360
1361 //----------------------------------------------------------------------
1362 // Wrappers for mipmap and image scaling entry points which dispatch either
1363 // to the Java or C versions.
1364 //
1365
1366 /** Interface to C language function: <br> <code> GLint gluBuild1DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */
gluBuild1DMipmapLevels(int target, int internalFormat, int width, int format, int type, int level, int base, int max, java.nio.Buffer data)1367 public int gluBuild1DMipmapLevels(int target, int internalFormat, int width, int format, int type, int level, int base, int max, java.nio.Buffer data) {
1368 if (useJavaMipmapCode) {
1369 return gluBuild1DMipmapLevelsJava(target, internalFormat, width, format, type, level, base, max, data);
1370 } else {
1371 return gluBuild1DMipmapLevelsC(target, internalFormat, width, format, type, level, base, max, data);
1372 }
1373 }
1374
1375 /** Interface to C language function: <br> <code> GLint gluBuild1DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void * data); </code> */
gluBuild1DMipmaps(int target, int internalFormat, int width, int format, int type, java.nio.Buffer data)1376 public int gluBuild1DMipmaps(int target, int internalFormat, int width, int format, int type, java.nio.Buffer data) {
1377 if (useJavaMipmapCode) {
1378 return gluBuild1DMipmapsJava(target, internalFormat, width, format, type, data);
1379 } else {
1380 return gluBuild1DMipmapsC(target, internalFormat, width, format, type, data);
1381 }
1382 }
1383
1384 /** Interface to C language function: <br> <code> GLint gluBuild2DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */
gluBuild2DMipmapLevels(int target, int internalFormat, int width, int height, int format, int type, int level, int base, int max, java.nio.Buffer data)1385 public int gluBuild2DMipmapLevels(int target, int internalFormat, int width, int height, int format, int type, int level, int base, int max, java.nio.Buffer data) {
1386 if (useJavaMipmapCode) {
1387 return gluBuild2DMipmapLevelsJava(target, internalFormat, width, height, format, type, level, base, max, data);
1388 } else {
1389 return gluBuild2DMipmapLevelsC(target, internalFormat, width, height, format, type, level, base, max, data);
1390 }
1391 }
1392
1393
1394 /** Interface to C language function: <br> <code> GLint gluBuild2DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * data); </code> */
gluBuild2DMipmaps(int target, int internalFormat, int width, int height, int format, int type, java.nio.Buffer data)1395 public int gluBuild2DMipmaps(int target, int internalFormat, int width, int height, int format, int type, java.nio.Buffer data) {
1396 if (useJavaMipmapCode) {
1397 return gluBuild2DMipmapsJava(target, internalFormat, width, height, format, type, data);
1398 } else {
1399 return gluBuild2DMipmapsC(target, internalFormat, width, height, format, type, data);
1400 }
1401 }
1402
1403
1404 /** Interface to C language function: <br> <code> GLint gluBuild3DMipmapLevels(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data); </code> */
gluBuild3DMipmapLevels(int target, int internalFormat, int width, int height, int depth, int format, int type, int level, int base, int max, java.nio.Buffer data)1405 public int gluBuild3DMipmapLevels(int target, int internalFormat, int width, int height, int depth, int format, int type, int level, int base, int max, java.nio.Buffer data) {
1406 if (useJavaMipmapCode) {
1407 return gluBuild3DMipmapLevelsJava(target, internalFormat, width, height, depth, format, type, level, base, max, data);
1408 } else {
1409 return gluBuild3DMipmapLevelsC(target, internalFormat, width, height, depth, format, type, level, base, max, data);
1410 }
1411 }
1412
1413 /** Interface to C language function: <br> <code> GLint gluBuild3DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * data); </code> */
gluBuild3DMipmaps(int target, int internalFormat, int width, int height, int depth, int format, int type, java.nio.Buffer data)1414 public int gluBuild3DMipmaps(int target, int internalFormat, int width, int height, int depth, int format, int type, java.nio.Buffer data) {
1415 if (useJavaMipmapCode) {
1416 return gluBuild3DMipmapsJava(target, internalFormat, width, height, depth, format, type, data);
1417 } else {
1418 return gluBuild3DMipmapsC(target, internalFormat, width, height, depth, format, type, data);
1419 }
1420 }
1421
1422
1423 /** Interface to C language function: <br> <code> GLint gluScaleImage(GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void * dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid * dataOut); </code> */
gluScaleImage(int format, int wIn, int hIn, int typeIn, java.nio.Buffer dataIn, int wOut, int hOut, int typeOut, java.nio.Buffer dataOut)1424 public int gluScaleImage(int format, int wIn, int hIn, int typeIn, java.nio.Buffer dataIn, int wOut, int hOut, int typeOut, java.nio.Buffer dataOut) {
1425 if (useJavaMipmapCode) {
1426 return gluScaleImageJava(format, wIn, hIn, typeIn, dataIn, wOut, hOut, typeOut, dataOut);
1427 } else {
1428 return gluScaleImageC(format, wIn, hIn, typeIn, dataIn, wOut, hOut, typeOut, dataOut);
1429 }
1430 }
1431
1432 //----------------------------------------------------------------------
1433 // NURBS functionality
1434 //
1435
1436 /**
1437 * Sets a property on a NURBS object. (NOTE: this function is not currently implemented.)
1438 *
1439 * @param r
1440 * GLUnurbs object holding NURBS to which a property should be
1441 * set
1442 * @param property
1443 * property id
1444 * @param value
1445 * property value
1446 */
gluNurbsProperty(GLUnurbs r, int property, float value)1447 public void gluNurbsProperty(GLUnurbs r, int property, float value) {
1448 // TODO glunurbsproperty
1449 float nurbsValue;
1450 switch (property) {
1451 default:
1452 // System.out.println("TODO gluwnurbs.glunurbsproperty");
1453 break;
1454 }
1455 }
1456
1457 /**
1458 * Creates a new GLUnurbs object.
1459 *
1460 * @return GLUnurbs object
1461 */
gluNewNurbsRenderer()1462 public GLUnurbs gluNewNurbsRenderer() {
1463 // DONE
1464 return new GLUnurbsImpl();
1465 }
1466
1467 /**
1468 * Begins a curve definition.
1469 *
1470 * @param r
1471 * GLUnurbs object to specify curve to
1472 */
gluBeginCurve(GLUnurbs r)1473 public void gluBeginCurve(GLUnurbs r) {
1474 // DONE
1475 ((GLUnurbsImpl) r).bgncurve();
1476 }
1477
1478 /**
1479 * Begins a surface definition.
1480 *
1481 * @param r
1482 * GLUnurbs object to specify surface to
1483 */
gluBeginSurface(GLUnurbs r)1484 public void gluBeginSurface(GLUnurbs r) {
1485 // DONE
1486 ((GLUnurbsImpl) r).bgnsurface();
1487 }
1488
1489 /**
1490 * Ends a surface.
1491 *
1492 * @param r
1493 * GLUnurbs object holding surface
1494 */
gluEndSurface(GLUnurbs r)1495 public void gluEndSurface(GLUnurbs r) {
1496 // DONE
1497 ((GLUnurbsImpl) r).endsurface();
1498 }
1499
1500 /**
1501 * Makes a NURBS surface.
1502 *
1503 * @param r
1504 * GLUnurbs object holding the surface
1505 * @param sknot_count
1506 * number of knots in s direction
1507 * @param sknot
1508 * knots in s direction
1509 * @param tknot_count
1510 * number of knots in t direction
1511 * @param tknot
1512 * knots in t direction
1513 * @param s_stride
1514 * number of control points coordinates in s direction
1515 * @param t_stride
1516 * number of control points coordinates in t direction
1517 * @param ctlarray
1518 * control points
1519 * @param sorder
1520 * order of surface in s direction
1521 * @param torder
1522 * order of surface in t direction
1523 * @param type
1524 * surface type
1525 */
gluNurbsSurface(GLUnurbs r, int sknot_count, float[] sknot, int tknot_count, float[] tknot, int s_stride, int t_stride, float[] ctlarray, int sorder, int torder, int type)1526 public void gluNurbsSurface(GLUnurbs r, int sknot_count, float[] sknot,
1527 int tknot_count, float[] tknot, int s_stride, int t_stride,
1528 float[] ctlarray, int sorder, int torder, int type) {
1529 // DONE
1530 ((GLUnurbsImpl) r).nurbssurface(sknot_count, sknot, tknot_count, tknot, s_stride,
1531 t_stride, ctlarray, sorder, torder, type);
1532 }
1533
1534 /**
1535 * Make a NURBS curve.
1536 *
1537 * @param r
1538 * GLUnurbs object holding the curve
1539 * @param nknots
1540 * number of knots
1541 * @param knot
1542 * knot vector
1543 * @param stride
1544 * number of control point coordinates
1545 * @param ctlarray
1546 * control points
1547 * @param order
1548 * order of the curve
1549 * @param type
1550 * curve type
1551 */
gluNurbsCurve(GLUnurbs r, int nknots, float[] knot, int stride, float[] ctlarray, int order, int type)1552 public void gluNurbsCurve(GLUnurbs r, int nknots, float[] knot, int stride,
1553 float[] ctlarray, int order, int type) {
1554 int realType;
1555 switch (type) {
1556 // TODO GLU_MAP1_TRIM_2 etc.
1557 default:
1558 realType = type;
1559 break;
1560 }
1561 ((GLUnurbsImpl) r).nurbscurve(nknots, knot, stride, ctlarray, order, realType);
1562 }
1563
1564 /**
1565 * Ends a curve definition.
1566 *
1567 * @param r
1568 * GLUnurbs object holding the curve
1569 */
gluEndCurve(GLUnurbs r)1570 public void gluEndCurve(GLUnurbs r) {
1571 //DONE
1572 ((GLUnurbsImpl) r).endcurve();
1573 }
1574
1575 //----------------------------------------------------------------------
1576 // GLUProcAddressTable handling
1577 //
1578
1579 private static GLUProcAddressTable gluProcAddressTable;
1580 private static volatile boolean gluLibraryLoaded;
1581
getGLUProcAddressTable()1582 private static GLUProcAddressTable getGLUProcAddressTable() {
1583 if (!gluLibraryLoaded) {
1584 loadGLULibrary();
1585 }
1586 if (gluProcAddressTable == null) {
1587 GLUProcAddressTable tmp = new GLUProcAddressTable();
1588 ProcAddressHelper.resetProcAddressTable(tmp, GLDrawableFactoryImpl.getFactoryImpl());
1589 gluProcAddressTable = tmp;
1590 }
1591 return gluProcAddressTable;
1592 }
1593
loadGLULibrary()1594 private static synchronized void loadGLULibrary() {
1595 if (!gluLibraryLoaded) {
1596 GLDrawableFactoryImpl.getFactoryImpl().loadGLULibrary();
1597 gluLibraryLoaded = true;
1598 }
1599 }
1600