JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
GLUgl2.java
Go to the documentation of this file.
1/* !---- DO NOT EDIT: This file autogenerated by com/jogamp/gluegen/opengl/GLEmitter.java on Sat Jul 12 19:19:59 CEST 2025 ----! */
2/* !---- Java-Unit: [pkg com.jogamp.opengl.glu.gl2, cls GLUgl2], ../build/jogl/gensrc/classes/com/jogamp/opengl/glu/gl2/GLUgl2.java ----! */
3
4package com.jogamp.opengl.glu.gl2;
5
6import com.jogamp.common.util.SecurityUtil;
7import jogamp.opengl.glu.nurbs.*;
8import java.security.*;
9import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver;
10import jogamp.opengl.glu.gl2.nurbs.*;
11import jogamp.opengl.glu.mipmap.Mipmap;
12import com.jogamp.opengl.GL2;
13import jogamp.opengl.gl2.ProjectDouble;
14import com.jogamp.opengl.*;
15import com.jogamp.opengl.glu.*;
16import com.jogamp.opengl.util.glsl.ShaderState;
17import jogamp.opengl.*;
18import jogamp.opengl.glu.*;
19import jogamp.opengl.glu.tessellator.GLUtessellatorImpl;
20import jogamp.opengl.ProjectFloat;
21import com.jogamp.common.util.ReflectionUtil;
22import com.jogamp.gluegen.runtime.*;
23import com.jogamp.common.os.*;
24import com.jogamp.common.nio.*;
25import java.nio.*;
26import com.jogamp.common.util.*;
27import java.util.Set;
28import java.util.Map;
29import java.util.HashMap;
30import java.nio.charset.Charset;
31import java.nio.charset.StandardCharsets;
32
33public class GLUgl2 extends GLU {
34 /** Entry point to C language function: <code> GLint {@native gluBuild1DMipmapLevels}(GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data) </code> <br>Part of <code>GLU_VERSION_1_X</code><br>
35 @param data a direct or array-backed {@link java.nio.Buffer} */
36 private int gluBuild1DMipmapLevelsC(int target, int internalFormat, int width, int format, int type, int level, int base, int max, Buffer data) {
37
38 final boolean data_is_direct = Buffers.isDirect(data);
39 final long __addr_ = getGLUProcAddressTable()._addressof_gluBuild1DMipmapLevels;
40 if (__addr_ == 0) {
41 throw new GLException(String.format("Method \"%s\" not available", "gluBuild1DMipmapLevels"));
42 }
43 return dispatch_gluBuild1DMipmapLevelsC1(target, internalFormat, width, format, type, level, base, max, data_is_direct ? data : Buffers.getArray(data), data_is_direct ? Buffers.getDirectBufferByteOffset(data) : Buffers.getIndirectBufferByteOffset(data), data_is_direct, __addr_);
44 }
45
46 /** Entry point to C language function: <code> GLint {@native gluBuild1DMipmapLevels}(GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data) </code> <br>Part of <code>GLU_VERSION_1_X</code><br>
47 @param data a direct or array-backed {@link java.nio.Buffer} */
48 private native int dispatch_gluBuild1DMipmapLevelsC1(int target, int internalFormat, int width, int format, int type, int level, int base, int max, Object data, int data_byte_offset, boolean data_is_direct, long procAddress);
49
50 /** Entry point to C language function: <code> GLint {@native gluBuild1DMipmaps}(GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void * data) </code> <br>Part of <code>GLU_VERSION_1_X</code><br>
51 @param data a direct or array-backed {@link java.nio.Buffer} */
52 private int gluBuild1DMipmapsC(int target, int internalFormat, int width, int format, int type, Buffer data) {
53
54 final boolean data_is_direct = Buffers.isDirect(data);
55 final long __addr_ = getGLUProcAddressTable()._addressof_gluBuild1DMipmaps;
56 if (__addr_ == 0) {
57 throw new GLException(String.format("Method \"%s\" not available", "gluBuild1DMipmaps"));
58 }
59 return dispatch_gluBuild1DMipmapsC1(target, internalFormat, width, format, type, data_is_direct ? data : Buffers.getArray(data), data_is_direct ? Buffers.getDirectBufferByteOffset(data) : Buffers.getIndirectBufferByteOffset(data), data_is_direct, __addr_);
60 }
61
62 /** Entry point to C language function: <code> GLint {@native gluBuild1DMipmaps}(GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void * data) </code> <br>Part of <code>GLU_VERSION_1_X</code><br>
63 @param data a direct or array-backed {@link java.nio.Buffer} */
64 private native int dispatch_gluBuild1DMipmapsC1(int target, int internalFormat, int width, int format, int type, Object data, int data_byte_offset, boolean data_is_direct, long procAddress);
65
66 /** Entry point to C language function: <code> GLint {@native gluBuild2DMipmapLevels}(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data) </code> <br>Part of <code>GLU_VERSION_1_X</code><br>
67 @param data a direct or array-backed {@link java.nio.Buffer} */
68 private int gluBuild2DMipmapLevelsC(int target, int internalFormat, int width, int height, int format, int type, int level, int base, int max, Buffer data) {
69
70 final boolean data_is_direct = Buffers.isDirect(data);
71 final long __addr_ = getGLUProcAddressTable()._addressof_gluBuild2DMipmapLevels;
72 if (__addr_ == 0) {
73 throw new GLException(String.format("Method \"%s\" not available", "gluBuild2DMipmapLevels"));
74 }
75 return dispatch_gluBuild2DMipmapLevelsC1(target, internalFormat, width, height, format, type, level, base, max, data_is_direct ? data : Buffers.getArray(data), data_is_direct ? Buffers.getDirectBufferByteOffset(data) : Buffers.getIndirectBufferByteOffset(data), data_is_direct, __addr_);
76 }
77
78 /** Entry point to C language function: <code> GLint {@native gluBuild2DMipmapLevels}(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void * data) </code> <br>Part of <code>GLU_VERSION_1_X</code><br>
79 @param data a direct or array-backed {@link java.nio.Buffer} */
80 private native int dispatch_gluBuild2DMipmapLevelsC1(int target, int internalFormat, int width, int height, int format, int type, int level, int base, int max, Object data, int data_byte_offset, boolean data_is_direct, long procAddress);
81
82 /** Entry point to C language function: <code> GLint {@native gluBuild2DMipmaps}(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * data) </code> <br>Part of <code>GLU_VERSION_1_X</code><br>
83 @param data a direct or array-backed {@link java.nio.Buffer} */
84 private int gluBuild2DMipmapsC(int target, int internalFormat, int width, int height, int format, int type, Buffer data) {
85
86 final boolean data_is_direct = Buffers.isDirect(data);
87 final long __addr_ = getGLUProcAddressTable()._addressof_gluBuild2DMipmaps;
88 if (__addr_ == 0) {
89 throw new GLException(String.format("Method \"%s\" not available", "gluBuild2DMipmaps"));
90 }
91 return dispatch_gluBuild2DMipmapsC1(target, internalFormat, width, height, format, type, data_is_direct ? data : Buffers.getArray(data), data_is_direct ? Buffers.getDirectBufferByteOffset(data) : Buffers.getIndirectBufferByteOffset(data), data_is_direct, __addr_);
92 }
93
94 /** Entry point to C language function: <code> GLint {@native gluBuild2DMipmaps}(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * data) </code> <br>Part of <code>GLU_VERSION_1_X</code><br>
95 @param data a direct or array-backed {@link java.nio.Buffer} */
96 private native int dispatch_gluBuild2DMipmapsC1(int target, int internalFormat, int width, int height, int format, int type, Object data, int data_byte_offset, boolean data_is_direct, long procAddress);
97
98 /** Entry point to C language function: <code> GLint {@native 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> <br>Part of <code>GLU_VERSION_1_X</code><br>
99 @param data a direct or array-backed {@link java.nio.Buffer} */
100 private int gluBuild3DMipmapLevelsC(int target, int internalFormat, int width, int height, int depth, int format, int type, int level, int base, int max, Buffer data) {
101
102 final boolean data_is_direct = Buffers.isDirect(data);
103 final long __addr_ = getGLUProcAddressTable()._addressof_gluBuild3DMipmapLevels;
104 if (__addr_ == 0) {
105 throw new GLException(String.format("Method \"%s\" not available", "gluBuild3DMipmapLevels"));
106 }
107 return dispatch_gluBuild3DMipmapLevelsC1(target, internalFormat, width, height, depth, format, type, level, base, max, data_is_direct ? data : Buffers.getArray(data), data_is_direct ? Buffers.getDirectBufferByteOffset(data) : Buffers.getIndirectBufferByteOffset(data), data_is_direct, __addr_);
108 }
109
110 /** Entry point to C language function: <code> GLint {@native 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> <br>Part of <code>GLU_VERSION_1_X</code><br>
111 @param data a direct or array-backed {@link java.nio.Buffer} */
112 private native int dispatch_gluBuild3DMipmapLevelsC1(int target, int internalFormat, int width, int height, int depth, int format, int type, int level, int base, int max, Object data, int data_byte_offset, boolean data_is_direct, long procAddress);
113
114 /** Entry point to C language function: <code> GLint {@native gluBuild3DMipmaps}(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * data) </code> <br>Part of <code>GLU_VERSION_1_X</code><br>
115 @param data a direct or array-backed {@link java.nio.Buffer} */
116 private int gluBuild3DMipmapsC(int target, int internalFormat, int width, int height, int depth, int format, int type, Buffer data) {
117
118 final boolean data_is_direct = Buffers.isDirect(data);
119 final long __addr_ = getGLUProcAddressTable()._addressof_gluBuild3DMipmaps;
120 if (__addr_ == 0) {
121 throw new GLException(String.format("Method \"%s\" not available", "gluBuild3DMipmaps"));
122 }
123 return dispatch_gluBuild3DMipmapsC1(target, internalFormat, width, height, depth, format, type, data_is_direct ? data : Buffers.getArray(data), data_is_direct ? Buffers.getDirectBufferByteOffset(data) : Buffers.getIndirectBufferByteOffset(data), data_is_direct, __addr_);
124 }
125
126 /** Entry point to C language function: <code> GLint {@native gluBuild3DMipmaps}(GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void * data) </code> <br>Part of <code>GLU_VERSION_1_X</code><br>
127 @param data a direct or array-backed {@link java.nio.Buffer} */
128 private native int dispatch_gluBuild3DMipmapsC1(int target, int internalFormat, int width, int height, int depth, int format, int type, Object data, int data_byte_offset, boolean data_is_direct, long procAddress);
129
130 /** Entry point to C language function: <code> GLint {@native gluScaleImage}(GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void * dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid * dataOut) </code> <br>Part of <code>GLU_VERSION_1_X</code><br>
131 @param dataIn a direct or array-backed {@link java.nio.Buffer}
132 @param dataOut a direct or array-backed {@link java.nio.Buffer} */
133 private int gluScaleImageC(int format, int wIn, int hIn, int typeIn, Buffer dataIn, int wOut, int hOut, int typeOut, Buffer dataOut) {
134
135 final boolean dataIn_is_direct = Buffers.isDirect(dataIn);
136 final boolean dataOut_is_direct = Buffers.isDirect(dataOut);
137 final long __addr_ = getGLUProcAddressTable()._addressof_gluScaleImage;
138 if (__addr_ == 0) {
139 throw new GLException(String.format("Method \"%s\" not available", "gluScaleImage"));
140 }
141 return dispatch_gluScaleImageC1(format, wIn, hIn, typeIn, dataIn_is_direct ? dataIn : Buffers.getArray(dataIn), dataIn_is_direct ? Buffers.getDirectBufferByteOffset(dataIn) : Buffers.getIndirectBufferByteOffset(dataIn), dataIn_is_direct, wOut, hOut, typeOut, dataOut_is_direct ? dataOut : Buffers.getArray(dataOut), dataOut_is_direct ? Buffers.getDirectBufferByteOffset(dataOut) : Buffers.getIndirectBufferByteOffset(dataOut), dataOut_is_direct, __addr_);
142 }
143
144 /** Entry point to C language function: <code> GLint {@native gluScaleImage}(GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void * dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid * dataOut) </code> <br>Part of <code>GLU_VERSION_1_X</code><br>
145 @param dataIn a direct or array-backed {@link java.nio.Buffer}
146 @param dataOut a direct or array-backed {@link java.nio.Buffer} */
147 private native int dispatch_gluScaleImageC1(int format, int wIn, int hIn, int typeIn, Object dataIn, int dataIn_byte_offset, boolean dataIn_is_direct, int wOut, int hOut, int typeOut, Object dataOut, int dataOut_byte_offset, boolean dataOut_is_direct, long procAddress);
148
149
150 // --- Begin CustomJavaCode .cfg declarations
151 private static boolean useJavaMipmapCode = true;
152
153 static {
154 SecurityUtil.doPrivileged(new PrivilegedAction() {
155 public Object run() {
156 String val = System.getProperty("jogl.glu.nojava");
157 if (val != null && !val.toLowerCase().equals("false")) {
158 useJavaMipmapCode = false;
159 }
160 /** Not required nor forced
161 if( !initializeImpl() ) {
162 throw new RuntimeException("Initialization failure");
163 } */
164 return null;
165 }
166 });
167 }
168
169 /**
170 * Instantiates a new OpenGL Utility Library object. A GLU object may
171 * be instantiated at any point in the application and is not
172 * inherently tied to any particular OpenGL context; however, the GLU
173 * object may only be used when an OpenGL context is current on the
174 * current thread. Attempts to call most of the methods in the GLU
175 * library when no OpenGL context is current will cause an exception
176 * to be thrown.
177 *
178 * <P>
179 *
180 * The returned GLU object is not guaranteed to be thread-safe and
181 * should only be used from one thread at a time. Multiple GLU objects
182 * may be instantiated to be used from different threads
183 * simultaneously.
184 */
185
186 public GLUgl2()
187 {
188 project = new ProjectDouble();
189 }
190
191 //----------------------------------------------------------------------
192 // Utility routines
193 //
194
195 public static final GL2 getCurrentGL2() throws GLException {
196 GLContext curContext = GLContext.getCurrent();
197 if (curContext == null) {
198 throw new GLException("No OpenGL context current on this thread");
199 }
200 return curContext.getGL().getGL2();
201 }
202
203 /**
204 * Returns true if the specified GLU core- or extension-function can be
205 * successfully used through this GLU instance. By "successfully" we mean
206 * that the function is both <i>callable</i> on the machine running the
207 * program and <i>available</i> on the current display.<P>
208 *
209 * A GLU function is <i>callable</i> if it is a GLU core- or extension-function
210 * that is supported by the underlying GLU implementation. The function is
211 * <i>available</i> if the OpenGL implementation on the display meets the
212 * requirements of the GLU function being called (because GLU functions utilize
213 * OpenGL functions). <P>
214 *
215 * Whether or not a GLU function is <i>callable</i> is determined as follows:
216 * <ul>
217 * <li>If the function is a GLU core function (i.e., not an
218 * extension), <code>gluGetString(GLU_VERSION)</code> is used to determine the
219 * version number of the underlying GLU implementation on the host.
220 * then the function name is cross-referenced with that specification to
221 * see if it is part of that version's specification.
222 *
223 * <li> If the function is a GLU extension, the function name is
224 * cross-referenced with the list returned by
225 * <code>gluGetString(GLU_EXTENSIONS)</code> to see if the function is one of
226 * the extensions that is supported by the underlying GLU implementation.
227 * </ul>
228 *
229 * Whether or not a GLU function is <i>available</i> is determined as follows:
230 * <ul>
231 * <li>If the function is a GLU core function then the function is first
232 * cross-referenced with the GLU specifications to find the minimum GLU
233 * version required to <i>call</i> that GLU function. Then the following table
234 * is consulted to determine the minimum GL version required for that version
235 * of GLU:
236 * <ul>
237 * <li> GLU 1.0 requires OpenGL 1.0
238 * <li> GLU 1.1 requires OpenGL 1.0
239 * <li> GLU 1.2 requires OpenGL 1.1
240 * <li> GLU 1.3 requires OpenGL 1.2
241 * </ul>
242 * Finally, <code>glGetString(GL_VERSION)</code> is used to determine the
243 * highest OpenGL version that both host and display support, and from that it
244 * is possible to determine if the GL facilities required by the GLU function
245 * are <i>available</i> on the display.
246 *
247 * <li> If the function is a GLU extension, the function name is
248 * cross-referenced with the list returned by
249 * <code>gluGetString(GLU_EXTENSIONS)</code> to see if the function is one of
250 * the extensions that is supported by the underlying GLU implementation.
251 * </ul>
252 *
253 * <b>NOTE:</b>The availability of a function may change at runtime in
254 * response to changes in the display environment. For example, when a window
255 * is dragged from one display to another on a multi-display system, or when
256 * the properties of the display device are modified (e.g., changing the color
257 * depth of the display). Any application that is concerned with handling
258 * these situations correctly should confirm availability after a display
259 * change before calling a questionable OpenGL function. To detect a change in
260 * the display device, please see {@link
261 * GLEventListener#displayChanged(GLAutoDrawable,boolean,boolean)}.
262 *
263 * @param gluFunctionName the name of the OpenGL function (e.g., use
264 * "gluNurbsCallbackDataEXT" to check if the <code>
265 * gluNurbsCallbackDataEXT(GLUnurbs, GLvoid)</code> extension is available).
266 */
267 public final boolean isFunctionAvailable(String gluFunctionName)
268 {
269 if (useJavaMipmapCode) {
270 // All GLU functions are available in Java port
271 return true;
272 }
273 return (gluProcAddressTable.getAddressFor(gluFunctionName) != 0);
274 }
275
276 //----------------------------------------------------------------------
277 // Projection routines
278 //
279
280 private final ProjectDouble project;
281
282 public final void gluOrtho2D(float left, float right, float bottom, float top) {
283 project.gluOrtho2D(getCurrentGL2(), (double)left, (double)right, (double)bottom, (double)top);
284
285 }
286
287 public final void gluOrtho2D(double left, double right, double bottom, double top) {
288 project.gluOrtho2D(getCurrentGL2(), left, right, bottom, top);
289 }
290
291 public final void gluPerspective(float fovy, float aspect, float zNear, float zFar) {
292 project.gluPerspective(getCurrentGL2(), (double)fovy, (double)aspect, (double)zNear, (double)zFar);
293 }
294
295 public final void gluPerspective(double fovy, double aspect, double zNear, double zFar) {
296 project.gluPerspective(getCurrentGL2(), fovy, aspect, zNear, zFar);
297 }
298
299 public final void gluLookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ) {
300 project.gluLookAt(getCurrentGL2(), (double)eyeX, (double)eyeY, (double)eyeZ, (double)centerX, (double)centerY, (double)centerZ, (double)upX, (double)upY, (double)upZ);
301 }
302
303 public final void gluLookAt(double eyeX, double eyeY, double eyeZ, double centerX, double centerY, double centerZ, double upX, double upY, double upZ) {
304 project.gluLookAt(getCurrentGL2(), eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ);
305 }
306
307 /** 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>
308 * <P> Accepts the outgoing window coordinates as a single array.
309 */
310 public final 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) {
311 return project.gluProject(objX, objY, objZ, model, model_offset, proj, proj_offset, view, view_offset, winPos, winPos_offset);
312 }
313
314 /** 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>
315 * <P> Accepts the outgoing window coordinates as a single buffer.
316 */
317 public final boolean gluProject(double objX, double objY, double objZ, DoubleBuffer model, DoubleBuffer proj, IntBuffer view, DoubleBuffer winPos) {
318 return project.gluProject(objX, objY, objZ, model, proj, view, winPos);
319 }
320
321 /** 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>
322 * <P> Accepts the outgoing object coordinates (a 3-vector) as a single array.
323 */
324 public final 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) {
325 return project.gluUnProject(winX, winY, winZ, model, model_offset, proj, proj_offset, view, view_offset, objPos, objPos_offset);
326 }
327
328 /** 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>
329 * <P> Accepts the outgoing object coordinates (a 3-vector) as a single buffer.
330 */
331 public final boolean gluUnProject(double winX, double winY, double winZ, DoubleBuffer model, DoubleBuffer proj, IntBuffer view, DoubleBuffer objPos) {
332 return project.gluUnProject(winX, winY, winZ, model, proj, view, objPos);
333 }
334
335 /** 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>
336 * <P> Accepts the outgoing object coordinates (a 4-vector) as a single array.
337 */
338 public final 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) {
339 return project.gluUnProject4(winX, winY, winZ, clipW, model, model_offset, proj, proj_offset, view, view_offset, nearVal, farVal, objPos, objPos_offset);
340 }
341
342 /** 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>
343 * <P> Accepts the outgoing object coordinates (a 4-vector) as a single buffer.
344 */
345 public final boolean gluUnProject4(double winX, double winY, double winZ, double clipW, DoubleBuffer model, DoubleBuffer proj, IntBuffer view, double nearVal, double farVal, DoubleBuffer objPos) {
346 return project.gluUnProject4(winX, winY, winZ, clipW, model, proj, view, nearVal, farVal, objPos);
347 }
348
349 public final void gluPickMatrix(double x, double y, double delX, double delY, int[] viewport, int viewport_offset) {
350 project.gluPickMatrix(getCurrentGL2(), x, y, delX, delY, viewport, viewport_offset);
351 }
352
353 public final void gluPickMatrix(double x, double y, double delX, double delY, IntBuffer viewport) {
354 project.gluPickMatrix(getCurrentGL2(), x, y, delX, delY, viewport);
355 }
356
357 //----------------------------------------------------------------------
358 // Mipmap and image scaling functionality
359
360
361 private final ByteBuffer copyToByteBuffer(Buffer buf) {
362 if (buf instanceof ByteBuffer) {
363 if (buf.position() == 0) {
364 return (ByteBuffer) buf;
365 }
366 return Buffers.copyByteBuffer((ByteBuffer) buf);
367 } else if (buf instanceof ShortBuffer) {
368 return Buffers.copyShortBufferAsByteBuffer((ShortBuffer) buf);
369 } else if (buf instanceof IntBuffer) {
370 return Buffers.copyIntBufferAsByteBuffer((IntBuffer) buf);
371 } else if (buf instanceof FloatBuffer) {
372 return Buffers.copyFloatBufferAsByteBuffer((FloatBuffer) buf);
373 } else {
374 throw new IllegalArgumentException("Unsupported buffer type (must be one of byte, short, int, or float)");
375 }
376 }
377
378 private final int gluScaleImageJava( int format, int widthin, int heightin,
379 int typein, Buffer datain, int widthout, int heightout,
380 int typeout, Buffer dataout ) {
381 ByteBuffer in = null;
382 ByteBuffer out = null;
383 in = copyToByteBuffer(datain);
384 if( dataout instanceof ByteBuffer ) {
385 out = (ByteBuffer)dataout;
386 } else if( dataout instanceof ShortBuffer ) {
387 out = Buffers.newDirectByteBuffer(dataout.remaining() * Buffers.SIZEOF_SHORT);
388 } else if ( dataout instanceof IntBuffer ) {
389 out = Buffers.newDirectByteBuffer(dataout.remaining() * Buffers.SIZEOF_INT);
390 } else if ( dataout instanceof FloatBuffer ) {
391 out = Buffers.newDirectByteBuffer(dataout.remaining() * Buffers.SIZEOF_FLOAT);
392 } else {
393 throw new IllegalArgumentException("Unsupported destination buffer type (must be byte, short, int, or float)");
394 }
395 int errno = Mipmap.gluScaleImage( getCurrentGL2(), format, widthin, heightin, typein, in,
396 widthout, heightout, typeout, out );
397 if( errno == 0 ) {
398 out.rewind();
399 if (out != dataout) {
400 if( dataout instanceof ShortBuffer ) {
401 ((ShortBuffer) dataout).put(out.asShortBuffer());
402 } else if( dataout instanceof IntBuffer ) {
403 ((IntBuffer) dataout).put(out.asIntBuffer());
404 } else if( dataout instanceof FloatBuffer ) {
405 ((FloatBuffer) dataout).put(out.asFloatBuffer());
406 } else {
407 throw new RuntimeException("Should not reach here");
408 }
409 }
410 }
411 return( errno );
412 }
413
414
415 private final int gluBuild1DMipmapLevelsJava( int target, int internalFormat, int width,
416 int format, int type, int userLevel, int baseLevel, int maxLevel,
417 Buffer data ) {
418 ByteBuffer buffer = copyToByteBuffer(data);
419 return( Mipmap.gluBuild1DMipmapLevels( getCurrentGL2(), target, internalFormat, width,
420 format, type, userLevel, baseLevel, maxLevel, buffer ) );
421 }
422
423
424 private final int gluBuild1DMipmapsJava( int target, int internalFormat, int width,
425 int format, int type, Buffer data ) {
426 ByteBuffer buffer = copyToByteBuffer(data);
427 return( Mipmap.gluBuild1DMipmaps( getCurrentGL2(), target, internalFormat, width, format,
428 type, buffer ) );
429 }
430
431
432 private final int gluBuild2DMipmapLevelsJava( int target, int internalFormat, int width,
433 int height, int format, int type, int userLevel, int baseLevel,
434 int maxLevel, Buffer data ) {
435 // While the code below handles other data types, it doesn't handle non-ByteBuffers
436 data = copyToByteBuffer(data);
437 return( Mipmap.gluBuild2DMipmapLevels( getCurrentGL2(), target, internalFormat, width,
438 height, format, type, userLevel, baseLevel, maxLevel, data ) );
439 }
440
441 private final int gluBuild2DMipmapsJava( int target, int internalFormat, int width,
442 int height, int format, int type, Buffer data ) {
443 // While the code below handles other data types, it doesn't handle non-ByteBuffers
444 data = copyToByteBuffer(data);
445 return( Mipmap.gluBuild2DMipmaps( getCurrentGL2(), target, internalFormat, width, height,
446 format, type, data) );
447 }
448
449 private final int gluBuild3DMipmapLevelsJava( int target, int internalFormat, int width,
450 int height, int depth, int format, int type, int userLevel, int baseLevel,
451 int maxLevel, Buffer data) {
452 ByteBuffer buffer = copyToByteBuffer(data);
453 return( Mipmap.gluBuild3DMipmapLevels( getCurrentGL2(), target, internalFormat, width,
454 height, depth, format, type, userLevel, baseLevel, maxLevel, buffer) );
455 }
456
457 private final int gluBuild3DMipmapsJava( int target, int internalFormat, int width,
458 int height, int depth, int format, int type, Buffer data ) {
459 ByteBuffer buffer = copyToByteBuffer(data);
460 return( Mipmap.gluBuild3DMipmaps( getCurrentGL2(), target, internalFormat, width, height,
461 depth, format, type, buffer ) );
462 }
463
464
465 //----------------------------------------------------------------------
466 // Wrappers for mipmap and image scaling entry points which dispatch either
467 // to the Java or C versions.
468 //
469
470 /** 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> */
471 public final int gluBuild1DMipmapLevels(int target, int internalFormat, int width, int format, int type, int level, int base, int max, java.nio.Buffer data) {
472 if (useJavaMipmapCode) {
473 return gluBuild1DMipmapLevelsJava(target, internalFormat, width, format, type, level, base, max, data);
474 } else {
475 return gluBuild1DMipmapLevelsC(target, internalFormat, width, format, type, level, base, max, data);
476 }
477 }
478
479 /** Interface to C language function: <br> <code> GLint gluBuild1DMipmaps(GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void * data); </code> */
480 public final int gluBuild1DMipmaps(int target, int internalFormat, int width, int format, int type, java.nio.Buffer data) {
481 if (useJavaMipmapCode) {
482 return gluBuild1DMipmapsJava(target, internalFormat, width, format, type, data);
483 } else {
484 return gluBuild1DMipmapsC(target, internalFormat, width, format, type, data);
485 }
486 }
487
488 /** 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> */
489 public final int gluBuild2DMipmapLevels(int target, int internalFormat, int width, int height, int format, int type, int level, int base, int max, java.nio.Buffer data) {
490 if (useJavaMipmapCode) {
491 return gluBuild2DMipmapLevelsJava(target, internalFormat, width, height, format, type, level, base, max, data);
492 } else {
493 return gluBuild2DMipmapLevelsC(target, internalFormat, width, height, format, type, level, base, max, data);
494 }
495 }
496
497
498 /** 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> */
499 public final int gluBuild2DMipmaps(int target, int internalFormat, int width, int height, int format, int type, java.nio.Buffer data) {
500 if (useJavaMipmapCode) {
501 return gluBuild2DMipmapsJava(target, internalFormat, width, height, format, type, data);
502 } else {
503 return gluBuild2DMipmapsC(target, internalFormat, width, height, format, type, data);
504 }
505 }
506
507
508 /** 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> */
509 public final 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) {
510 if (useJavaMipmapCode) {
511 return gluBuild3DMipmapLevelsJava(target, internalFormat, width, height, depth, format, type, level, base, max, data);
512 } else {
513 return gluBuild3DMipmapLevelsC(target, internalFormat, width, height, depth, format, type, level, base, max, data);
514 }
515 }
516
517 /** 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> */
518 public final int gluBuild3DMipmaps(int target, int internalFormat, int width, int height, int depth, int format, int type, java.nio.Buffer data) {
519 if (useJavaMipmapCode) {
520 return gluBuild3DMipmapsJava(target, internalFormat, width, height, depth, format, type, data);
521 } else {
522 return gluBuild3DMipmapsC(target, internalFormat, width, height, depth, format, type, data);
523 }
524 }
525
526
527 /** 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> */
528 public final int gluScaleImage(int format, int wIn, int hIn, int typeIn, java.nio.Buffer dataIn, int wOut, int hOut, int typeOut, java.nio.Buffer dataOut) {
529 if (useJavaMipmapCode) {
530 return gluScaleImageJava(format, wIn, hIn, typeIn, dataIn, wOut, hOut, typeOut, dataOut);
531 } else {
532 return gluScaleImageC(format, wIn, hIn, typeIn, dataIn, wOut, hOut, typeOut, dataOut);
533 }
534 }
535
536 //----------------------------------------------------------------------
537 // NURBS functionality
538 //
539
540 /**
541 * Sets a property on a NURBS object. (NOTE: this function is not currently implemented.)
542 *
543 * @param r
544 * GLUnurbs object holding NURBS to which a property should be
545 * set
546 * @param property
547 * property id
548 * @param value
549 * property value
550 */
551 public final void gluNurbsProperty(GLUnurbs r, int property, float value) {
552 // TODO glunurbsproperty
553 float nurbsValue;
554 switch (property) {
555 default:
556 // System.out.println("TODO gluwnurbs.glunurbsproperty");
557 break;
558 }
559 }
560
561 /**
562 * Creates a new GLUnurbs object.
563 *
564 * @return GLUnurbs object
565 */
567 // DONE
568 return new GLUgl2nurbsImpl();
569 }
570
571 /**
572 * Begins a curve definition.
573 *
574 * @param r
575 * GLUnurbs object to specify curve to
576 */
577 public final void gluBeginCurve(GLUnurbs r) {
578 // DONE
579 ((GLUgl2nurbsImpl) r).bgncurve();
580 }
581
582 /**
583 * Begins a surface definition.
584 *
585 * @param r
586 * GLUnurbs object to specify surface to
587 */
588 public final void gluBeginSurface(GLUnurbs r) {
589 // DONE
590 ((GLUgl2nurbsImpl) r).bgnsurface();
591 }
592
593 /**
594 * Ends a surface.
595 *
596 * @param r
597 * GLUnurbs object holding surface
598 */
599 public final void gluEndSurface(GLUnurbs r) {
600 // DONE
601 ((GLUgl2nurbsImpl) r).endsurface();
602 }
603
604 /**
605 * Makes a NURBS surface.
606 *
607 * @param r
608 * GLUnurbs object holding the surface
609 * @param sknot_count
610 * number of knots in s direction
611 * @param sknot
612 * knots in s direction
613 * @param tknot_count
614 * number of knots in t direction
615 * @param tknot
616 * knots in t direction
617 * @param s_stride
618 * number of control points coordinates in s direction
619 * @param t_stride
620 * number of control points coordinates in t direction
621 * @param ctlarray
622 * control points
623 * @param sorder
624 * order of surface in s direction
625 * @param torder
626 * order of surface in t direction
627 * @param type
628 * surface type
629 */
630 public final void gluNurbsSurface(GLUnurbs r, int sknot_count, float[] sknot,
631 int tknot_count, float[] tknot, int s_stride, int t_stride,
632 float[] ctlarray, int sorder, int torder, int type) {
633 // DONE
634 ((GLUgl2nurbsImpl) r).nurbssurface(sknot_count, sknot, tknot_count, tknot, s_stride,
635 t_stride, ctlarray, sorder, torder, type);
636 }
637
638 /**
639 * Make a NURBS curve.
640 *
641 * @param r
642 * GLUnurbs object holding the curve
643 * @param nknots
644 * number of knots
645 * @param knot
646 * knot vector
647 * @param stride
648 * number of control point coordinates
649 * @param ctlarray
650 * control points
651 * @param order
652 * order of the curve
653 * @param type
654 * curve type
655 */
656 public final void gluNurbsCurve(GLUnurbs r, int nknots, float[] knot, int stride,
657 float[] ctlarray, int order, int type) {
658 int realType;
659 switch (type) {
660 // TODO GLU_MAP1_TRIM_2 etc.
661 default:
662 realType = type;
663 break;
664 }
665 ((GLUgl2nurbsImpl) r).nurbscurve(nknots, knot, stride, ctlarray, order, realType);
666 }
667
668 /**
669 * Ends a curve definition.
670 *
671 * @param r
672 * GLUnurbs object holding the curve
673 */
674 public final void gluEndCurve(GLUnurbs r) {
675 //DONE
676 ((GLUgl2nurbsImpl) r).endcurve();
677 }
678
679 //----------------------------------------------------------------------
680 // GLUProcAddressTable handling
681 //
682
683 private static GLUgl2ProcAddressTable gluProcAddressTable;
684
685 private static final GLUgl2ProcAddressTable getGLUProcAddressTable() {
686 if (gluProcAddressTable == null) {
687 GLContext curContext = GLContext.getCurrent();
688 if (curContext == null) {
689 throw new GLException("No OpenGL context current on this thread");
690 }
691 GLDynamicLookupHelper glLookupHelper = ((GLContextImpl) curContext).getGLDynamicLookupHelper();
692 glLookupHelper.loadGLULibrary();
693 GLUgl2ProcAddressTable tmp = new GLUgl2ProcAddressTable(new GLProcAddressResolver());
694 tmp.reset(glLookupHelper);
695 gluProcAddressTable = tmp;
696 }
697 return gluProcAddressTable;
698 }
699 // ---- End CustomJavaCode .cfg declarations
700} // end of class GLUgl2
Abstraction for an OpenGL rendering context.
Definition: GLContext.java:74
static GLContext getCurrent()
Returns this thread current context.
Definition: GLContext.java:515
abstract GL getGL()
Returns the GL pipeline object for this GLContext.
A generic exception for OpenGL errors used throughout the binding as a substitute for RuntimeExceptio...
Provides access to the OpenGL Utility Library (GLU).
Definition: GLU.java:43
final void 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)
Makes a NURBS surface.
Definition: GLUgl2.java:630
final void gluLookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ)
Definition: GLUgl2.java:299
static final GL2 getCurrentGL2()
Definition: GLUgl2.java:195
final int gluBuild3DMipmaps(int target, int internalFormat, int width, int height, int depth, int format, int type, java.nio.Buffer data)
Interface to C language function: GLint gluBuild3DMipmaps(GLenum target, GLint internalFormat,...
Definition: GLUgl2.java:518
final int gluScaleImage(int format, int wIn, int hIn, int typeIn, java.nio.Buffer dataIn, int wOut, int hOut, int typeOut, java.nio.Buffer dataOut)
Interface to C language function: GLint gluScaleImage(GLenum format, GLsizei wIn,...
Definition: GLUgl2.java:528
final void gluPickMatrix(double x, double y, double delX, double delY, IntBuffer viewport)
Definition: GLUgl2.java:353
final void gluPerspective(double fovy, double aspect, double zNear, double zFar)
Definition: GLUgl2.java:295
final int gluBuild2DMipmaps(int target, int internalFormat, int width, int height, int format, int type, java.nio.Buffer data)
Interface to C language function: GLint gluBuild2DMipmaps(GLenum target, GLint internalFormat,...
Definition: GLUgl2.java:499
final void gluEndSurface(GLUnurbs r)
Ends a surface.
Definition: GLUgl2.java:599
final void gluOrtho2D(double left, double right, double bottom, double top)
Definition: GLUgl2.java:287
final GLUnurbs gluNewNurbsRenderer()
Creates a new GLUnurbs object.
Definition: GLUgl2.java:566
final 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)
Interface to C language function: GLint gluBuild3DMipmapLevels(GLenum target, GLint internalFormat...
Definition: GLUgl2.java:509
final void gluBeginCurve(GLUnurbs r)
Begins a curve definition.
Definition: GLUgl2.java:577
final void gluLookAt(double eyeX, double eyeY, double eyeZ, double centerX, double centerY, double centerZ, double upX, double upY, double upZ)
Definition: GLUgl2.java:303
final void gluBeginSurface(GLUnurbs r)
Begins a surface definition.
Definition: GLUgl2.java:588
GLUgl2()
Instantiates a new OpenGL Utility Library object.
Definition: GLUgl2.java:186
final void gluPickMatrix(double x, double y, double delX, double delY, int[] viewport, int viewport_offset)
Definition: GLUgl2.java:349
final 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)
Interface to C language function: GLint gluProject(GLdouble objX, GLdouble objY,...
Definition: GLUgl2.java:310
final void gluOrtho2D(float left, float right, float bottom, float top)
Definition: GLUgl2.java:282
final int gluBuild1DMipmapLevels(int target, int internalFormat, int width, int format, int type, int level, int base, int max, java.nio.Buffer data)
Interface to C language function: GLint gluBuild1DMipmapLevels(GLenum target, GLint internalFormat...
Definition: GLUgl2.java:471
final int gluBuild2DMipmapLevels(int target, int internalFormat, int width, int height, int format, int type, int level, int base, int max, java.nio.Buffer data)
Interface to C language function: GLint gluBuild2DMipmapLevels(GLenum target, GLint internalFormat...
Definition: GLUgl2.java:489
final void gluPerspective(float fovy, float aspect, float zNear, float zFar)
Definition: GLUgl2.java:291
final void gluNurbsCurve(GLUnurbs r, int nknots, float[] knot, int stride, float[] ctlarray, int order, int type)
Make a NURBS curve.
Definition: GLUgl2.java:656
final int gluBuild1DMipmaps(int target, int internalFormat, int width, int format, int type, java.nio.Buffer data)
Interface to C language function: GLint gluBuild1DMipmaps(GLenum target, GLint internalFormat,...
Definition: GLUgl2.java:480
final boolean gluUnProject4(double winX, double winY, double winZ, double clipW, DoubleBuffer model, DoubleBuffer proj, IntBuffer view, double nearVal, double farVal, DoubleBuffer objPos)
Interface to C language function: GLint gluUnProject4(GLdouble winX, GLdouble winY,...
Definition: GLUgl2.java:345
final void gluNurbsProperty(GLUnurbs r, int property, float value)
Sets a property on a NURBS object.
Definition: GLUgl2.java:551
final boolean gluProject(double objX, double objY, double objZ, DoubleBuffer model, DoubleBuffer proj, IntBuffer view, DoubleBuffer winPos)
Interface to C language function: GLint gluProject(GLdouble objX, GLdouble objY,...
Definition: GLUgl2.java:317
final 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)
Interface to C language function: GLint gluUnProject4(GLdouble winX, GLdouble winY,...
Definition: GLUgl2.java:338
final boolean gluUnProject(double winX, double winY, double winZ, DoubleBuffer model, DoubleBuffer proj, IntBuffer view, DoubleBuffer objPos)
Interface to C language function: GLint gluUnProject(GLdouble winX, GLdouble winY,...
Definition: GLUgl2.java:331
final void gluEndCurve(GLUnurbs r)
Ends a curve definition.
Definition: GLUgl2.java:674
final boolean isFunctionAvailable(String gluFunctionName)
Returns true if the specified GLU core- or extension-function can be successfully used through this G...
Definition: GLUgl2.java:267
final 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)
Interface to C language function: GLint gluUnProject(GLdouble winX, GLdouble winY,...
Definition: GLUgl2.java:324
GL2 getGL2()
Casts this object to the GL2 interface.
Wrapper for a GLU NURBS object.
Definition: GLUnurbs.java:7