propane 2.7.2-java → 2.8.0.pre-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +10 -0
  3. data/CHANGELOG.md +1 -1
  4. data/README.md +10 -8
  5. data/Rakefile +1 -1
  6. data/lib/propane/app.rb +3 -3
  7. data/lib/propane/version.rb +1 -1
  8. data/lib/{processing-core.jar → propane-2.8.0.jar} +0 -0
  9. data/library/control_panel/control_panel.rb +3 -2
  10. data/pom.rb +89 -88
  11. data/pom.xml +75 -46
  12. data/propane.gemspec +1 -2
  13. data/src/main/java/japplemenubar/JAppleMenuBar.java +88 -0
  14. data/src/main/java/japplemenubar/libjAppleMenuBar.jnilib +0 -0
  15. data/src/{monkstone → main/java/monkstone}/ColorUtil.java +0 -0
  16. data/src/{monkstone → main/java/monkstone}/MathToolModule.java +0 -0
  17. data/src/{monkstone → main/java/monkstone}/PropaneLibrary.java +0 -0
  18. data/src/{monkstone → main/java/monkstone}/core/LibraryProxy.java +0 -0
  19. data/src/{monkstone → main/java/monkstone}/fastmath/Deglut.java +0 -0
  20. data/src/{monkstone → main/java/monkstone}/fastmath/package-info.java +0 -0
  21. data/src/{monkstone → main/java/monkstone}/filechooser/Chooser.java +0 -0
  22. data/src/{monkstone → main/java/monkstone}/noise/SimplexNoise.java +0 -0
  23. data/src/{monkstone → main/java/monkstone}/slider/CustomHorizontalSlider.java +0 -0
  24. data/src/{monkstone → main/java/monkstone}/slider/CustomVerticalSlider.java +0 -0
  25. data/src/{monkstone → main/java/monkstone}/slider/SimpleHorizontalSlider.java +0 -0
  26. data/src/{monkstone → main/java/monkstone}/slider/SimpleSlider.java +0 -0
  27. data/src/{monkstone → main/java/monkstone}/slider/SimpleVerticalSlider.java +0 -0
  28. data/src/{monkstone → main/java/monkstone}/slider/Slider.java +0 -0
  29. data/src/{monkstone → main/java/monkstone}/slider/SliderBar.java +0 -0
  30. data/src/{monkstone → main/java/monkstone}/slider/SliderGroup.java +0 -0
  31. data/src/{monkstone → main/java/monkstone}/slider/WheelHandler.java +0 -0
  32. data/src/{monkstone → main/java/monkstone}/vecmath/AppRender.java +0 -0
  33. data/src/{monkstone → main/java/monkstone}/vecmath/JRender.java +0 -0
  34. data/src/{monkstone → main/java/monkstone}/vecmath/ShapeRender.java +0 -0
  35. data/src/{monkstone → main/java/monkstone}/vecmath/package-info.java +0 -0
  36. data/src/{monkstone → main/java/monkstone}/vecmath/vec2/Vec2.java +0 -0
  37. data/src/{monkstone → main/java/monkstone}/vecmath/vec2/package-info.java +0 -0
  38. data/src/{monkstone → main/java/monkstone}/vecmath/vec3/Vec3.java +0 -0
  39. data/src/{monkstone → main/java/monkstone}/vecmath/vec3/package-info.java +0 -0
  40. data/src/{monkstone → main/java/monkstone}/videoevent/VideoInterface.java +0 -0
  41. data/src/{monkstone → main/java/monkstone}/videoevent/package-info.java +0 -0
  42. data/src/main/java/processing/awt/PGraphicsJava2D.java +3029 -0
  43. data/src/main/java/processing/awt/PShapeJava2D.java +377 -0
  44. data/src/main/java/processing/awt/PSurfaceAWT.java +1567 -0
  45. data/src/main/java/processing/core/PApplet.java +15709 -0
  46. data/src/main/java/processing/core/PConstants.java +527 -0
  47. data/src/main/java/processing/core/PFont.java +1098 -0
  48. data/src/main/java/processing/core/PGraphics.java +8467 -0
  49. data/src/main/java/processing/core/PImage.java +3438 -0
  50. data/src/main/java/processing/core/PMatrix.java +208 -0
  51. data/src/main/java/processing/core/PMatrix2D.java +534 -0
  52. data/src/main/java/processing/core/PMatrix3D.java +877 -0
  53. data/src/main/java/processing/core/PShape.java +3445 -0
  54. data/src/main/java/processing/core/PShapeOBJ.java +469 -0
  55. data/src/main/java/processing/core/PShapeSVG.java +1787 -0
  56. data/src/main/java/processing/core/PStyle.java +63 -0
  57. data/src/main/java/processing/core/PSurface.java +161 -0
  58. data/src/main/java/processing/core/PSurfaceNone.java +374 -0
  59. data/src/main/java/processing/core/PVector.java +1063 -0
  60. data/src/main/java/processing/data/FloatDict.java +829 -0
  61. data/src/main/java/processing/data/FloatList.java +912 -0
  62. data/src/main/java/processing/data/IntDict.java +796 -0
  63. data/src/main/java/processing/data/IntList.java +913 -0
  64. data/src/main/java/processing/data/JSONArray.java +1260 -0
  65. data/src/main/java/processing/data/JSONObject.java +2282 -0
  66. data/src/main/java/processing/data/JSONTokener.java +435 -0
  67. data/src/main/java/processing/data/Sort.java +46 -0
  68. data/src/main/java/processing/data/StringDict.java +601 -0
  69. data/src/main/java/processing/data/StringList.java +775 -0
  70. data/src/main/java/processing/data/Table.java +4923 -0
  71. data/src/main/java/processing/data/TableRow.java +198 -0
  72. data/src/main/java/processing/data/XML.java +1149 -0
  73. data/src/main/java/processing/event/Event.java +125 -0
  74. data/src/main/java/processing/event/KeyEvent.java +70 -0
  75. data/src/main/java/processing/event/MouseEvent.java +149 -0
  76. data/src/main/java/processing/event/TouchEvent.java +57 -0
  77. data/src/main/java/processing/opengl/FontTexture.java +379 -0
  78. data/src/main/java/processing/opengl/FrameBuffer.java +503 -0
  79. data/src/main/java/processing/opengl/LinePath.java +623 -0
  80. data/src/main/java/processing/opengl/LineStroker.java +685 -0
  81. data/src/main/java/processing/opengl/PGL.java +3366 -0
  82. data/src/main/java/processing/opengl/PGraphics2D.java +615 -0
  83. data/src/main/java/processing/opengl/PGraphics3D.java +281 -0
  84. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +13634 -0
  85. data/src/main/java/processing/opengl/PJOGL.java +1966 -0
  86. data/src/main/java/processing/opengl/PShader.java +1478 -0
  87. data/src/main/java/processing/opengl/PShapeOpenGL.java +5234 -0
  88. data/src/main/java/processing/opengl/PSurfaceJOGL.java +1315 -0
  89. data/src/main/java/processing/opengl/Texture.java +1670 -0
  90. data/src/main/java/processing/opengl/VertexBuffer.java +88 -0
  91. data/src/main/java/processing/opengl/cursors/arrow.png +0 -0
  92. data/src/main/java/processing/opengl/cursors/cross.png +0 -0
  93. data/src/main/java/processing/opengl/cursors/hand.png +0 -0
  94. data/src/main/java/processing/opengl/cursors/license.txt +27 -0
  95. data/src/main/java/processing/opengl/cursors/move.png +0 -0
  96. data/src/main/java/processing/opengl/cursors/text.png +0 -0
  97. data/src/main/java/processing/opengl/cursors/wait.png +0 -0
  98. data/src/main/java/processing/opengl/shaders/ColorFrag.glsl +32 -0
  99. data/src/main/java/processing/opengl/shaders/ColorVert.glsl +34 -0
  100. data/src/main/java/processing/opengl/shaders/LightFrag.glsl +33 -0
  101. data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +154 -0
  102. data/src/main/java/processing/opengl/shaders/LightVert.glsl +151 -0
  103. data/src/main/java/processing/opengl/shaders/LineFrag.glsl +32 -0
  104. data/src/main/java/processing/opengl/shaders/LineVert.glsl +100 -0
  105. data/src/main/java/processing/opengl/shaders/MaskFrag.glsl +40 -0
  106. data/src/main/java/processing/opengl/shaders/PointFrag.glsl +32 -0
  107. data/src/main/java/processing/opengl/shaders/PointVert.glsl +56 -0
  108. data/src/main/java/processing/opengl/shaders/TexFrag.glsl +37 -0
  109. data/src/main/java/processing/opengl/shaders/TexLightFrag.glsl +37 -0
  110. data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +160 -0
  111. data/src/main/java/processing/opengl/shaders/TexLightVert.glsl +157 -0
  112. data/src/main/java/processing/opengl/shaders/TexVert.glsl +38 -0
  113. data/src/main/resources/icon/icon-1024.png +0 -0
  114. data/src/main/resources/icon/icon-128.png +0 -0
  115. data/src/main/resources/icon/icon-16.png +0 -0
  116. data/src/main/resources/icon/icon-256.png +0 -0
  117. data/src/main/resources/icon/icon-32.png +0 -0
  118. data/src/main/resources/icon/icon-48.png +0 -0
  119. data/src/main/resources/icon/icon-512.png +0 -0
  120. data/src/main/resources/icon/icon-64.png +0 -0
  121. data/src/main/resources/license.txt +508 -0
  122. data/vendors/Rakefile +5 -20
  123. metadata +115 -33
  124. data/lib/propane.jar +0 -0
@@ -0,0 +1,1966 @@
1
+ /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
+
3
+ /*
4
+ Part of the Processing project - http://processing.org
5
+
6
+ Copyright (c) 2012-15 The Processing Foundation
7
+ Copyright (c) 2004-12 Ben Fry and Casey Reas
8
+ Copyright (c) 2001-04 Massachusetts Institute of Technology
9
+
10
+ This library is free software; you can redistribute it and/or
11
+ modify it under the terms of the GNU Lesser General Public
12
+ License as published by the Free Software Foundation, version 2.1.
13
+
14
+ This library is distributed in the hope that it will be useful,
15
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
+ Lesser General Public License for more details.
18
+
19
+ You should have received a copy of the GNU Lesser General
20
+ Public License along with this library; if not, write to the
21
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22
+ Boston, MA 02111-1307 USA
23
+ */
24
+
25
+ package processing.opengl;
26
+
27
+ import java.awt.Font;
28
+ import java.awt.FontMetrics;
29
+ import java.awt.Shape;
30
+ import java.awt.Toolkit;
31
+ import java.awt.font.FontRenderContext;
32
+ import java.awt.font.GlyphVector;
33
+ import java.awt.geom.PathIterator;
34
+ import java.io.IOException;
35
+ import java.net.URL;
36
+ import java.nio.Buffer;
37
+ import java.nio.ByteBuffer;
38
+ import java.nio.FloatBuffer;
39
+ import java.nio.IntBuffer;
40
+
41
+ import com.jogamp.common.util.VersionNumber;
42
+ import com.jogamp.opengl.GL;
43
+ import com.jogamp.opengl.GL2;
44
+ import com.jogamp.opengl.GL2ES2;
45
+ import com.jogamp.opengl.GL2ES3;
46
+ import com.jogamp.opengl.GL2GL3;
47
+ import com.jogamp.opengl.GL3ES3;
48
+ import com.jogamp.opengl.GLAutoDrawable;
49
+ import com.jogamp.opengl.GLCapabilities;
50
+ import com.jogamp.opengl.GLCapabilitiesImmutable;
51
+ import com.jogamp.opengl.GLContext;
52
+ import com.jogamp.opengl.GLDrawable;
53
+ import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
54
+ import com.jogamp.opengl.glu.GLU;
55
+ import com.jogamp.opengl.glu.GLUtessellator;
56
+ import com.jogamp.opengl.glu.GLUtessellatorCallbackAdapter;
57
+
58
+ import processing.core.PApplet;
59
+ import processing.core.PGraphics;
60
+ import processing.core.PMatrix3D;
61
+ import processing.core.PSurface;
62
+
63
+
64
+ public class PJOGL extends PGL {
65
+ // OpenGL profile to use (2, 3 or 4)
66
+ public static int profile = 2;
67
+
68
+ // User-provided icons to override defaults
69
+ protected static String[] icons = null;
70
+
71
+ // The two windowing toolkits available to use in JOGL:
72
+ public static final int AWT = 0; // http://jogamp.org/wiki/index.php/Using_JOGL_in_AWT_SWT_and_Swing
73
+ public static final int NEWT = 1; // http://jogamp.org/jogl/doc/NEWT-Overview.html
74
+
75
+ // ........................................................
76
+
77
+ // Public members to access the underlying GL objects and context
78
+
79
+ /** Basic GL functionality, common to all profiles */
80
+ public GL gl;
81
+
82
+ /** GLU interface **/
83
+ public GLU glu;
84
+
85
+ /** The rendering context (holds rendering state info) */
86
+ public GLContext context;
87
+
88
+ // ........................................................
89
+
90
+ // Additional parameters
91
+
92
+ /** Time that the Processing's animation thread will wait for JOGL's rendering
93
+ * thread to be done with a single frame.
94
+ */
95
+ protected static int DRAW_TIMEOUT_MILLIS = 500;
96
+
97
+ // ........................................................
98
+
99
+ // Protected JOGL-specific objects needed to access the GL profiles
100
+
101
+ /** The capabilities of the OpenGL rendering surface */
102
+ protected GLCapabilitiesImmutable capabilities;
103
+
104
+ /** The rendering surface */
105
+ protected GLDrawable drawable;
106
+
107
+ /** GLES2 functionality (shaders, etc) */
108
+ protected GL2ES2 gl2;
109
+
110
+ /** GL3 interface */
111
+ protected GL2GL3 gl3;
112
+
113
+ /** GL2 desktop functionality (blit framebuffer, map buffer range,
114
+ * multisampled renderbuffers) */
115
+ protected GL2 gl2x;
116
+
117
+ /** GL3ES3 interface */
118
+ protected GL3ES3 gl3es3;
119
+
120
+ /** Stores exceptions that ocurred during drawing */
121
+ protected Exception drawException;
122
+
123
+ // ........................................................
124
+
125
+ // Utility arrays to copy projection/modelview matrices to GL
126
+
127
+ protected float[] projMatrix;
128
+ protected float[] mvMatrix;
129
+
130
+ // ........................................................
131
+
132
+ // Static initialization for some parameters that need to be different for
133
+ // JOGL
134
+
135
+ static {
136
+ MIN_DIRECT_BUFFER_SIZE = 2;
137
+ INDEX_TYPE = GL.GL_UNSIGNED_SHORT;
138
+ }
139
+
140
+
141
+ ///////////////////////////////////////////////////////////////
142
+
143
+ // Initialization, finalization
144
+
145
+
146
+ public PJOGL(PGraphicsOpenGL pg) {
147
+ super(pg);
148
+ glu = new GLU();
149
+ }
150
+
151
+
152
+ @Override
153
+ public Object getNative() {
154
+ return sketch.getSurface().getNative();
155
+ }
156
+
157
+
158
+ @Override
159
+ protected void setFrameRate(float fps) {}
160
+
161
+
162
+ @Override
163
+ protected void initSurface(int antialias) {}
164
+
165
+
166
+ @Override
167
+ protected void reinitSurface() {}
168
+
169
+
170
+ @Override
171
+ protected void registerListeners() {}
172
+
173
+
174
+ static public void setIcon(String... icons) {
175
+ PJOGL.icons = new String[icons.length];
176
+ PApplet.arrayCopy(icons, PJOGL.icons);
177
+ }
178
+
179
+
180
+ ///////////////////////////////////////////////////////////////
181
+
182
+ // Public methods to get/set renderer's properties
183
+
184
+
185
+ public void setCaps(GLCapabilities caps) {
186
+ reqNumSamples = caps.getNumSamples();
187
+ capabilities = caps;
188
+ }
189
+
190
+
191
+ public GLCapabilitiesImmutable getCaps() {
192
+ return capabilities;
193
+ }
194
+
195
+
196
+ public void setFps(float fps) {
197
+ if (!setFps || targetFps != fps) {
198
+ if (60 < fps) {
199
+ // Disables v-sync
200
+ gl.setSwapInterval(0);
201
+ } else if (30 < fps) {
202
+ gl.setSwapInterval(1);
203
+ } else {
204
+ gl.setSwapInterval(2);
205
+ }
206
+ targetFps = currentFps = fps;
207
+ setFps = true;
208
+ }
209
+ }
210
+
211
+
212
+ @Override
213
+ protected int getDepthBits() {
214
+ return capabilities.getDepthBits();
215
+ }
216
+
217
+
218
+ @Override
219
+ protected int getStencilBits() {
220
+ return capabilities.getStencilBits();
221
+ }
222
+
223
+
224
+ @Override
225
+ protected float getPixelScale() {
226
+ PSurface surf = sketch.getSurface();
227
+ if (surf == null) {
228
+ return graphics.pixelDensity;
229
+ } else if (surf instanceof PSurfaceJOGL) {
230
+ return ((PSurfaceJOGL)surf).getPixelScale();
231
+ } else {
232
+ throw new RuntimeException("Renderer cannot find a JOGL surface");
233
+ }
234
+ }
235
+
236
+
237
+ @Override
238
+ protected void getGL(PGL pgl) {
239
+ PJOGL pjogl = (PJOGL)pgl;
240
+
241
+ this.drawable = pjogl.drawable;
242
+ this.context = pjogl.context;
243
+ this.glContext = pjogl.glContext;
244
+ setThread(pjogl.glThread);
245
+
246
+ this.gl = pjogl.gl;
247
+ this.gl2 = pjogl.gl2;
248
+ this.gl2x = pjogl.gl2x;
249
+ this.gl3 = pjogl.gl3;
250
+ this.gl3es3 = pjogl.gl3es3;
251
+ }
252
+
253
+
254
+ public void getGL(GLAutoDrawable glDrawable) {
255
+ context = glDrawable.getContext();
256
+ glContext = context.hashCode();
257
+ setThread(Thread.currentThread());
258
+
259
+ gl = context.getGL();
260
+ gl2 = gl.getGL2ES2();
261
+ try {
262
+ gl2x = gl.getGL2();
263
+ } catch (com.jogamp.opengl.GLException e) {
264
+ gl2x = null;
265
+ }
266
+ try {
267
+ gl3 = gl.getGL2GL3();
268
+ } catch (com.jogamp.opengl.GLException e) {
269
+ gl3 = null;
270
+ }
271
+ try {
272
+ gl3es3 = gl.getGL3ES3();
273
+ } catch (com.jogamp.opengl.GLException e) {
274
+ gl3es3 = null;
275
+ }
276
+ }
277
+
278
+
279
+ @Override
280
+ protected boolean canDraw() { return true; }
281
+
282
+
283
+ @Override
284
+ protected void requestFocus() {}
285
+
286
+
287
+ @Override
288
+ protected void requestDraw() {}
289
+
290
+
291
+ @Override
292
+ protected void swapBuffers() {
293
+ PSurfaceJOGL surf = (PSurfaceJOGL)sketch.getSurface();
294
+ surf.window.swapBuffers();
295
+ }
296
+
297
+
298
+ @Override
299
+ protected void initFBOLayer() {
300
+ if (0 < sketch.frameCount) {
301
+ if (isES()) initFBOLayerES();
302
+ else initFBOLayerGL();
303
+ }
304
+ }
305
+
306
+
307
+ private void initFBOLayerES() {
308
+ IntBuffer buf = allocateDirectIntBuffer(fboWidth * fboHeight);
309
+
310
+ if (hasReadBuffer()) readBuffer(BACK);
311
+ readPixelsImpl(0, 0, fboWidth, fboHeight, RGBA, UNSIGNED_BYTE, buf);
312
+ bindTexture(TEXTURE_2D, glColorTex.get(frontTex));
313
+ texSubImage2D(TEXTURE_2D, 0, 0, 0, fboWidth, fboHeight, RGBA, UNSIGNED_BYTE, buf);
314
+
315
+ bindTexture(TEXTURE_2D, glColorTex.get(backTex));
316
+ texSubImage2D(TEXTURE_2D, 0, 0, 0, fboWidth, fboHeight, RGBA, UNSIGNED_BYTE, buf);
317
+
318
+ bindTexture(TEXTURE_2D, 0);
319
+ bindFramebufferImpl(FRAMEBUFFER, 0);
320
+ }
321
+
322
+
323
+ private void initFBOLayerGL() {
324
+ // Copy the contents of the front and back screen buffers to the textures
325
+ // of the FBO, so they are properly initialized. Note that the front buffer
326
+ // of the default framebuffer (the screen) contains the previous frame:
327
+ // https://www.opengl.org/wiki/Default_Framebuffer
328
+ // so it is copied to the front texture of the FBO layer:
329
+ if (pclearColor || 0 < pgeomCount || !sketch.isLooping()) {
330
+ if (hasReadBuffer()) readBuffer(FRONT);
331
+ } else {
332
+ // ...except when the previous frame has not been cleared and nothing was
333
+ // rendered while looping. In this case the back buffer, which holds the
334
+ // initial state of the previous frame, still contains the most up-to-date
335
+ // screen state.
336
+ readBuffer(BACK);
337
+ }
338
+ bindFramebufferImpl(DRAW_FRAMEBUFFER, glColorFbo.get(0));
339
+ framebufferTexture2D(FRAMEBUFFER, COLOR_ATTACHMENT0,
340
+ TEXTURE_2D, glColorTex.get(frontTex), 0);
341
+ if (hasDrawBuffer()) drawBuffer(COLOR_ATTACHMENT0);
342
+ blitFramebuffer(0, 0, fboWidth, fboHeight,
343
+ 0, 0, fboWidth, fboHeight,
344
+ COLOR_BUFFER_BIT, NEAREST);
345
+
346
+ readBuffer(BACK);
347
+ bindFramebufferImpl(DRAW_FRAMEBUFFER, glColorFbo.get(0));
348
+ framebufferTexture2D(FRAMEBUFFER, COLOR_ATTACHMENT0,
349
+ TEXTURE_2D, glColorTex.get(backTex), 0);
350
+ drawBuffer(COLOR_ATTACHMENT0);
351
+ blitFramebuffer(0, 0, fboWidth, fboHeight,
352
+ 0, 0, fboWidth, fboHeight,
353
+ COLOR_BUFFER_BIT, NEAREST);
354
+
355
+ bindFramebufferImpl(FRAMEBUFFER, 0);
356
+ }
357
+
358
+
359
+ @Override
360
+ protected void beginGL() {
361
+ PMatrix3D proj = graphics.projection;
362
+ PMatrix3D mdl = graphics.modelview;
363
+ if (gl2x != null) {
364
+ if (projMatrix == null) {
365
+ projMatrix = new float[16];
366
+ }
367
+ gl2x.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
368
+ projMatrix[ 0] = proj.m00;
369
+ projMatrix[ 1] = proj.m10;
370
+ projMatrix[ 2] = proj.m20;
371
+ projMatrix[ 3] = proj.m30;
372
+ projMatrix[ 4] = proj.m01;
373
+ projMatrix[ 5] = proj.m11;
374
+ projMatrix[ 6] = proj.m21;
375
+ projMatrix[ 7] = proj.m31;
376
+ projMatrix[ 8] = proj.m02;
377
+ projMatrix[ 9] = proj.m12;
378
+ projMatrix[10] = proj.m22;
379
+ projMatrix[11] = proj.m32;
380
+ projMatrix[12] = proj.m03;
381
+ projMatrix[13] = proj.m13;
382
+ projMatrix[14] = proj.m23;
383
+ projMatrix[15] = proj.m33;
384
+ gl2x.glLoadMatrixf(projMatrix, 0);
385
+
386
+ if (mvMatrix == null) {
387
+ mvMatrix = new float[16];
388
+ }
389
+ gl2x.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
390
+ mvMatrix[ 0] = mdl.m00;
391
+ mvMatrix[ 1] = mdl.m10;
392
+ mvMatrix[ 2] = mdl.m20;
393
+ mvMatrix[ 3] = mdl.m30;
394
+ mvMatrix[ 4] = mdl.m01;
395
+ mvMatrix[ 5] = mdl.m11;
396
+ mvMatrix[ 6] = mdl.m21;
397
+ mvMatrix[ 7] = mdl.m31;
398
+ mvMatrix[ 8] = mdl.m02;
399
+ mvMatrix[ 9] = mdl.m12;
400
+ mvMatrix[10] = mdl.m22;
401
+ mvMatrix[11] = mdl.m32;
402
+ mvMatrix[12] = mdl.m03;
403
+ mvMatrix[13] = mdl.m13;
404
+ mvMatrix[14] = mdl.m23;
405
+ mvMatrix[15] = mdl.m33;
406
+ gl2x.glLoadMatrixf(mvMatrix, 0);
407
+ }
408
+ }
409
+
410
+
411
+ @Override
412
+ protected boolean hasFBOs() {
413
+ if (context.hasBasicFBOSupport()) return true;
414
+ else return super.hasFBOs();
415
+ }
416
+
417
+
418
+ @Override
419
+ protected boolean hasShaders() {
420
+ if (context.hasGLSL()) return true;
421
+ else return super.hasShaders();
422
+ }
423
+
424
+
425
+ public void init(GLAutoDrawable glDrawable) {
426
+ capabilities = glDrawable.getChosenGLCapabilities();
427
+ if (!hasFBOs()) {
428
+ throw new RuntimeException(MISSING_FBO_ERROR);
429
+ }
430
+ if (!hasShaders()) {
431
+ throw new RuntimeException(MISSING_GLSL_ERROR);
432
+ }
433
+ }
434
+
435
+
436
+ ///////////////////////////////////////////////////////////
437
+
438
+ // Utility functions
439
+
440
+
441
+ @Override
442
+ protected void enableTexturing(int target) {
443
+ if (target == TEXTURE_2D) {
444
+ texturingTargets[0] = true;
445
+ } else if (target == TEXTURE_RECTANGLE) {
446
+ texturingTargets[1] = true;
447
+ }
448
+ }
449
+
450
+
451
+ @Override
452
+ protected void disableTexturing(int target) {
453
+ if (target == TEXTURE_2D) {
454
+ texturingTargets[0] = false;
455
+ } else if (target == TEXTURE_RECTANGLE) {
456
+ texturingTargets[1] = false;
457
+ }
458
+ }
459
+
460
+
461
+ /**
462
+ * Convenience method to get a legit FontMetrics object. Where possible,
463
+ * override this any renderer subclass so that you're not using what's
464
+ * returned by getDefaultToolkit() to get your metrics.
465
+ */
466
+ @SuppressWarnings("deprecation")
467
+ private FontMetrics getFontMetrics(Font font) { // ignore
468
+ return Toolkit.getDefaultToolkit().getFontMetrics(font);
469
+ }
470
+
471
+
472
+ /**
473
+ * Convenience method to jump through some Java2D hoops and get an FRC.
474
+ */
475
+ private FontRenderContext getFontRenderContext(Font font) { // ignore
476
+ return getFontMetrics(font).getFontRenderContext();
477
+ }
478
+
479
+
480
+ @Override
481
+ protected int getFontAscent(Object font) {
482
+ return getFontMetrics((Font) font).getAscent();
483
+ }
484
+
485
+
486
+ @Override
487
+ protected int getFontDescent(Object font) {
488
+ return getFontMetrics((Font) font).getDescent();
489
+ }
490
+
491
+
492
+ @Override
493
+ protected int getTextWidth(Object font, char[] buffer, int start, int stop) {
494
+ // maybe should use one of the newer/fancier functions for this?
495
+ int length = stop - start;
496
+ FontMetrics metrics = getFontMetrics((Font) font);
497
+ return metrics.charsWidth(buffer, start, length);
498
+ }
499
+
500
+
501
+ @Override
502
+ protected Object getDerivedFont(Object font, float size) {
503
+ return ((Font) font).deriveFont(size);
504
+ }
505
+
506
+ @Override
507
+ protected int getGLSLVersion() {
508
+ VersionNumber vn = context.getGLSLVersionNumber();
509
+ return vn.getMajor() * 100 + vn.getMinor();
510
+ }
511
+
512
+
513
+ @Override
514
+ protected String[] loadVertexShader(String filename) {
515
+ return loadVertexShader(filename, getGLSLVersion());
516
+ }
517
+
518
+
519
+ @Override
520
+ protected String[] loadFragmentShader(String filename) {
521
+ return loadFragmentShader(filename, getGLSLVersion());
522
+ }
523
+
524
+
525
+ @Override
526
+ protected String[] loadVertexShader(URL url) {
527
+ return loadVertexShader(url, getGLSLVersion());
528
+ }
529
+
530
+
531
+ @Override
532
+ protected String[] loadFragmentShader(URL url) {
533
+ return loadFragmentShader(url, getGLSLVersion());
534
+ }
535
+
536
+
537
+ @Override
538
+ protected String[] loadFragmentShader(String filename, int version) {
539
+ String[] fragSrc0 = sketch.loadStrings(filename);
540
+ return preprocessFragmentSource(fragSrc0, version);
541
+ }
542
+
543
+
544
+ @Override
545
+ protected String[] loadVertexShader(String filename, int version) {
546
+ String[] vertSrc0 = sketch.loadStrings(filename);
547
+ return preprocessVertexSource(vertSrc0, version);
548
+ }
549
+
550
+
551
+ @Override
552
+ protected String[] loadFragmentShader(URL url, int version) {
553
+ try {
554
+ String[] fragSrc0 = PApplet.loadStrings(url.openStream());
555
+ return preprocessFragmentSource(fragSrc0, version);
556
+ } catch (IOException e) {
557
+ PGraphics.showException("Cannot load fragment shader " + url.getFile());
558
+ }
559
+ return null;
560
+ }
561
+
562
+
563
+ @Override
564
+ protected String[] loadVertexShader(URL url, int version) {
565
+ try {
566
+ String[] vertSrc0 = PApplet.loadStrings(url.openStream());
567
+ return preprocessVertexSource(vertSrc0, version);
568
+ } catch (IOException e) {
569
+ PGraphics.showException("Cannot load vertex shader " + url.getFile());
570
+ }
571
+ return null;
572
+ }
573
+
574
+
575
+ ///////////////////////////////////////////////////////////
576
+
577
+ // Tessellator
578
+
579
+
580
+ @Override
581
+ protected Tessellator createTessellator(TessellatorCallback callback) {
582
+ return new Tessellator(callback);
583
+ }
584
+
585
+
586
+ protected static class Tessellator implements PGL.Tessellator {
587
+ protected GLUtessellator tess;
588
+ protected TessellatorCallback callback;
589
+ protected GLUCallback gluCallback;
590
+
591
+ public Tessellator(TessellatorCallback callback) {
592
+ this.callback = callback;
593
+ tess = GLU.gluNewTess();
594
+ gluCallback = new GLUCallback();
595
+
596
+ GLU.gluTessCallback(tess, GLU.GLU_TESS_BEGIN, gluCallback);
597
+ GLU.gluTessCallback(tess, GLU.GLU_TESS_END, gluCallback);
598
+ GLU.gluTessCallback(tess, GLU.GLU_TESS_VERTEX, gluCallback);
599
+ GLU.gluTessCallback(tess, GLU.GLU_TESS_COMBINE, gluCallback);
600
+ GLU.gluTessCallback(tess, GLU.GLU_TESS_ERROR, gluCallback);
601
+ }
602
+
603
+ @Override
604
+ public void setCallback(int flag) {
605
+ GLU.gluTessCallback(tess, flag, gluCallback);
606
+ }
607
+
608
+ @Override
609
+ public void setWindingRule(int rule) {
610
+ setProperty(GLU.GLU_TESS_WINDING_RULE, rule);
611
+ }
612
+
613
+ public void setProperty(int property, int value) {
614
+ GLU.gluTessProperty(tess, property, value);
615
+ }
616
+
617
+ @Override
618
+ public void beginPolygon() {
619
+ beginPolygon(null);
620
+ }
621
+
622
+ @Override
623
+ public void beginPolygon(Object data) {
624
+ GLU.gluTessBeginPolygon(tess, data);
625
+ }
626
+
627
+ @Override
628
+ public void endPolygon() {
629
+ GLU.gluTessEndPolygon(tess);
630
+ }
631
+
632
+ @Override
633
+ public void beginContour() {
634
+ GLU.gluTessBeginContour(tess);
635
+ }
636
+
637
+ @Override
638
+ public void endContour() {
639
+ GLU.gluTessEndContour(tess);
640
+ }
641
+
642
+ @Override
643
+ public void addVertex(double[] v) {
644
+ addVertex(v, 0, v);
645
+ }
646
+
647
+ @Override
648
+ public void addVertex(double[] v, int n, Object data) {
649
+ GLU.gluTessVertex(tess, v, n, data);
650
+ }
651
+
652
+ protected class GLUCallback extends GLUtessellatorCallbackAdapter {
653
+ @Override
654
+ public void begin(int type) {
655
+ callback.begin(type);
656
+ }
657
+
658
+ @Override
659
+ public void end() {
660
+ callback.end();
661
+ }
662
+
663
+ @Override
664
+ public void vertex(Object data) {
665
+ callback.vertex(data);
666
+ }
667
+
668
+ @Override
669
+ public void combine(double[] coords, Object[] data,
670
+ float[] weight, Object[] outData) {
671
+ callback.combine(coords, data, weight, outData);
672
+ }
673
+
674
+ @Override
675
+ public void error(int errnum) {
676
+ callback.error(errnum);
677
+ }
678
+ }
679
+ }
680
+
681
+
682
+ @Override
683
+ protected String tessError(int err) {
684
+ return glu.gluErrorString(err);
685
+ }
686
+
687
+
688
+ ///////////////////////////////////////////////////////////
689
+
690
+ // Font outline
691
+
692
+
693
+ static {
694
+ SHAPE_TEXT_SUPPORTED = true;
695
+ SEG_MOVETO = PathIterator.SEG_MOVETO;
696
+ SEG_LINETO = PathIterator.SEG_LINETO;
697
+ SEG_QUADTO = PathIterator.SEG_QUADTO;
698
+ SEG_CUBICTO = PathIterator.SEG_CUBICTO;
699
+ SEG_CLOSE = PathIterator.SEG_CLOSE;
700
+ }
701
+
702
+
703
+ @Override
704
+ protected FontOutline createFontOutline(char ch, Object font) {
705
+ return new FontOutline(ch, (Font) font);
706
+ }
707
+
708
+
709
+ protected class FontOutline implements PGL.FontOutline {
710
+ PathIterator iter;
711
+
712
+ public FontOutline(char ch, Font font) {
713
+ char textArray[] = new char[] { ch };
714
+ FontRenderContext frc = getFontRenderContext(font);
715
+ GlyphVector gv = font.createGlyphVector(frc, textArray);
716
+ Shape shp = gv.getOutline();
717
+ iter = shp.getPathIterator(null);
718
+ }
719
+
720
+ public boolean isDone() {
721
+ return iter.isDone();
722
+ }
723
+
724
+ public int currentSegment(float coords[]) {
725
+ return iter.currentSegment(coords);
726
+ }
727
+
728
+ public void next() {
729
+ iter.next();
730
+ }
731
+ }
732
+
733
+
734
+ ///////////////////////////////////////////////////////////
735
+
736
+ // Constants
737
+
738
+ static {
739
+ FALSE = GL.GL_FALSE;
740
+ TRUE = GL.GL_TRUE;
741
+
742
+ INT = GL2ES2.GL_INT;
743
+ BYTE = GL.GL_BYTE;
744
+ SHORT = GL.GL_SHORT;
745
+ FLOAT = GL.GL_FLOAT;
746
+ BOOL = GL2ES2.GL_BOOL;
747
+ UNSIGNED_INT = GL.GL_UNSIGNED_INT;
748
+ UNSIGNED_BYTE = GL.GL_UNSIGNED_BYTE;
749
+ UNSIGNED_SHORT = GL.GL_UNSIGNED_SHORT;
750
+
751
+ RGB = GL.GL_RGB;
752
+ RGBA = GL.GL_RGBA;
753
+ ALPHA = GL.GL_ALPHA;
754
+ LUMINANCE = GL.GL_LUMINANCE;
755
+ LUMINANCE_ALPHA = GL.GL_LUMINANCE_ALPHA;
756
+
757
+ UNSIGNED_SHORT_5_6_5 = GL.GL_UNSIGNED_SHORT_5_6_5;
758
+ UNSIGNED_SHORT_4_4_4_4 = GL.GL_UNSIGNED_SHORT_4_4_4_4;
759
+ UNSIGNED_SHORT_5_5_5_1 = GL.GL_UNSIGNED_SHORT_5_5_5_1;
760
+
761
+ RGBA4 = GL.GL_RGBA4;
762
+ RGB5_A1 = GL.GL_RGB5_A1;
763
+ RGB565 = GL.GL_RGB565;
764
+ RGB8 = GL.GL_RGB8;
765
+ RGBA8 = GL.GL_RGBA8;
766
+ ALPHA8 = GL.GL_ALPHA8;
767
+
768
+ READ_ONLY = GL2ES3.GL_READ_ONLY;
769
+ WRITE_ONLY = GL.GL_WRITE_ONLY;
770
+ READ_WRITE = GL2ES3.GL_READ_WRITE;
771
+
772
+ TESS_WINDING_NONZERO = GLU.GLU_TESS_WINDING_NONZERO;
773
+ TESS_WINDING_ODD = GLU.GLU_TESS_WINDING_ODD;
774
+ TESS_EDGE_FLAG = GLU.GLU_TESS_EDGE_FLAG;
775
+
776
+ GENERATE_MIPMAP_HINT = GL.GL_GENERATE_MIPMAP_HINT;
777
+ FASTEST = GL.GL_FASTEST;
778
+ NICEST = GL.GL_NICEST;
779
+ DONT_CARE = GL.GL_DONT_CARE;
780
+
781
+ VENDOR = GL.GL_VENDOR;
782
+ RENDERER = GL.GL_RENDERER;
783
+ VERSION = GL.GL_VERSION;
784
+ EXTENSIONS = GL.GL_EXTENSIONS;
785
+ SHADING_LANGUAGE_VERSION = GL2ES2.GL_SHADING_LANGUAGE_VERSION;
786
+
787
+ MAX_SAMPLES = GL.GL_MAX_SAMPLES;
788
+ SAMPLES = GL.GL_SAMPLES;
789
+
790
+ ALIASED_LINE_WIDTH_RANGE = GL.GL_ALIASED_LINE_WIDTH_RANGE;
791
+ ALIASED_POINT_SIZE_RANGE = GL.GL_ALIASED_POINT_SIZE_RANGE;
792
+
793
+ DEPTH_BITS = GL.GL_DEPTH_BITS;
794
+ STENCIL_BITS = GL.GL_STENCIL_BITS;
795
+
796
+ CCW = GL.GL_CCW;
797
+ CW = GL.GL_CW;
798
+
799
+ VIEWPORT = GL.GL_VIEWPORT;
800
+
801
+ ARRAY_BUFFER = GL.GL_ARRAY_BUFFER;
802
+ ELEMENT_ARRAY_BUFFER = GL.GL_ELEMENT_ARRAY_BUFFER;
803
+ PIXEL_PACK_BUFFER = GL2ES3.GL_PIXEL_PACK_BUFFER;
804
+
805
+ MAX_VERTEX_ATTRIBS = GL2ES2.GL_MAX_VERTEX_ATTRIBS;
806
+
807
+ STATIC_DRAW = GL.GL_STATIC_DRAW;
808
+ DYNAMIC_DRAW = GL.GL_DYNAMIC_DRAW;
809
+ STREAM_DRAW = GL2ES2.GL_STREAM_DRAW;
810
+ STREAM_READ = GL2ES3.GL_STREAM_READ;
811
+
812
+ BUFFER_SIZE = GL.GL_BUFFER_SIZE;
813
+ BUFFER_USAGE = GL.GL_BUFFER_USAGE;
814
+
815
+ POINTS = GL.GL_POINTS;
816
+ LINE_STRIP = GL.GL_LINE_STRIP;
817
+ LINE_LOOP = GL.GL_LINE_LOOP;
818
+ LINES = GL.GL_LINES;
819
+ TRIANGLE_FAN = GL.GL_TRIANGLE_FAN;
820
+ TRIANGLE_STRIP = GL.GL_TRIANGLE_STRIP;
821
+ TRIANGLES = GL.GL_TRIANGLES;
822
+
823
+ CULL_FACE = GL.GL_CULL_FACE;
824
+ FRONT = GL.GL_FRONT;
825
+ BACK = GL.GL_BACK;
826
+ FRONT_AND_BACK = GL.GL_FRONT_AND_BACK;
827
+
828
+ POLYGON_OFFSET_FILL = GL.GL_POLYGON_OFFSET_FILL;
829
+
830
+ UNPACK_ALIGNMENT = GL.GL_UNPACK_ALIGNMENT;
831
+ PACK_ALIGNMENT = GL.GL_PACK_ALIGNMENT;
832
+
833
+ TEXTURE_2D = GL.GL_TEXTURE_2D;
834
+ TEXTURE_RECTANGLE = GL2GL3.GL_TEXTURE_RECTANGLE;
835
+
836
+ TEXTURE_BINDING_2D = GL.GL_TEXTURE_BINDING_2D;
837
+ TEXTURE_BINDING_RECTANGLE = GL2GL3.GL_TEXTURE_BINDING_RECTANGLE;
838
+
839
+ MAX_TEXTURE_SIZE = GL.GL_MAX_TEXTURE_SIZE;
840
+ TEXTURE_MAX_ANISOTROPY = GL.GL_TEXTURE_MAX_ANISOTROPY_EXT;
841
+ MAX_TEXTURE_MAX_ANISOTROPY = GL.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT;
842
+
843
+ MAX_VERTEX_TEXTURE_IMAGE_UNITS = GL2ES2.GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS;
844
+ MAX_TEXTURE_IMAGE_UNITS = GL2ES2.GL_MAX_TEXTURE_IMAGE_UNITS;
845
+ MAX_COMBINED_TEXTURE_IMAGE_UNITS = GL2ES2.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS;
846
+
847
+ NUM_COMPRESSED_TEXTURE_FORMATS = GL.GL_NUM_COMPRESSED_TEXTURE_FORMATS;
848
+ COMPRESSED_TEXTURE_FORMATS = GL.GL_COMPRESSED_TEXTURE_FORMATS;
849
+
850
+ NEAREST = GL.GL_NEAREST;
851
+ LINEAR = GL.GL_LINEAR;
852
+ LINEAR_MIPMAP_NEAREST = GL.GL_LINEAR_MIPMAP_NEAREST;
853
+ LINEAR_MIPMAP_LINEAR = GL.GL_LINEAR_MIPMAP_LINEAR;
854
+
855
+ CLAMP_TO_EDGE = GL.GL_CLAMP_TO_EDGE;
856
+ REPEAT = GL.GL_REPEAT;
857
+
858
+ TEXTURE0 = GL.GL_TEXTURE0;
859
+ TEXTURE1 = GL.GL_TEXTURE1;
860
+ TEXTURE2 = GL.GL_TEXTURE2;
861
+ TEXTURE3 = GL.GL_TEXTURE3;
862
+ TEXTURE_MIN_FILTER = GL.GL_TEXTURE_MIN_FILTER;
863
+ TEXTURE_MAG_FILTER = GL.GL_TEXTURE_MAG_FILTER;
864
+ TEXTURE_WRAP_S = GL.GL_TEXTURE_WRAP_S;
865
+ TEXTURE_WRAP_T = GL.GL_TEXTURE_WRAP_T;
866
+ TEXTURE_WRAP_R = GL2ES2.GL_TEXTURE_WRAP_R;
867
+
868
+ TEXTURE_CUBE_MAP = GL.GL_TEXTURE_CUBE_MAP;
869
+ TEXTURE_CUBE_MAP_POSITIVE_X = GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X;
870
+ TEXTURE_CUBE_MAP_POSITIVE_Y = GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y;
871
+ TEXTURE_CUBE_MAP_POSITIVE_Z = GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Z;
872
+ TEXTURE_CUBE_MAP_NEGATIVE_X = GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X;
873
+ TEXTURE_CUBE_MAP_NEGATIVE_Y = GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y;
874
+ TEXTURE_CUBE_MAP_NEGATIVE_Z = GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z;
875
+
876
+ VERTEX_SHADER = GL2ES2.GL_VERTEX_SHADER;
877
+ FRAGMENT_SHADER = GL2ES2.GL_FRAGMENT_SHADER;
878
+ INFO_LOG_LENGTH = GL2ES2.GL_INFO_LOG_LENGTH;
879
+ SHADER_SOURCE_LENGTH = GL2ES2.GL_SHADER_SOURCE_LENGTH;
880
+ COMPILE_STATUS = GL2ES2.GL_COMPILE_STATUS;
881
+ LINK_STATUS = GL2ES2.GL_LINK_STATUS;
882
+ VALIDATE_STATUS = GL2ES2.GL_VALIDATE_STATUS;
883
+ SHADER_TYPE = GL2ES2.GL_SHADER_TYPE;
884
+ DELETE_STATUS = GL2ES2.GL_DELETE_STATUS;
885
+
886
+ FLOAT_VEC2 = GL2ES2.GL_FLOAT_VEC2;
887
+ FLOAT_VEC3 = GL2ES2.GL_FLOAT_VEC3;
888
+ FLOAT_VEC4 = GL2ES2.GL_FLOAT_VEC4;
889
+ FLOAT_MAT2 = GL2ES2.GL_FLOAT_MAT2;
890
+ FLOAT_MAT3 = GL2ES2.GL_FLOAT_MAT3;
891
+ FLOAT_MAT4 = GL2ES2.GL_FLOAT_MAT4;
892
+ INT_VEC2 = GL2ES2.GL_INT_VEC2;
893
+ INT_VEC3 = GL2ES2.GL_INT_VEC3;
894
+ INT_VEC4 = GL2ES2.GL_INT_VEC4;
895
+ BOOL_VEC2 = GL2ES2.GL_BOOL_VEC2;
896
+ BOOL_VEC3 = GL2ES2.GL_BOOL_VEC3;
897
+ BOOL_VEC4 = GL2ES2.GL_BOOL_VEC4;
898
+ SAMPLER_2D = GL2ES2.GL_SAMPLER_2D;
899
+ SAMPLER_CUBE = GL2ES2.GL_SAMPLER_CUBE;
900
+
901
+ LOW_FLOAT = GL2ES2.GL_LOW_FLOAT;
902
+ MEDIUM_FLOAT = GL2ES2.GL_MEDIUM_FLOAT;
903
+ HIGH_FLOAT = GL2ES2.GL_HIGH_FLOAT;
904
+ LOW_INT = GL2ES2.GL_LOW_INT;
905
+ MEDIUM_INT = GL2ES2.GL_MEDIUM_INT;
906
+ HIGH_INT = GL2ES2.GL_HIGH_INT;
907
+
908
+ CURRENT_VERTEX_ATTRIB = GL2ES2.GL_CURRENT_VERTEX_ATTRIB;
909
+
910
+ VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING;
911
+ VERTEX_ATTRIB_ARRAY_ENABLED = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_ENABLED;
912
+ VERTEX_ATTRIB_ARRAY_SIZE = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_SIZE;
913
+ VERTEX_ATTRIB_ARRAY_STRIDE = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_STRIDE;
914
+ VERTEX_ATTRIB_ARRAY_TYPE = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_TYPE;
915
+ VERTEX_ATTRIB_ARRAY_NORMALIZED = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_NORMALIZED;
916
+ VERTEX_ATTRIB_ARRAY_POINTER = GL2ES2.GL_VERTEX_ATTRIB_ARRAY_POINTER;
917
+
918
+ BLEND = GL.GL_BLEND;
919
+ ONE = GL.GL_ONE;
920
+ ZERO = GL.GL_ZERO;
921
+ SRC_ALPHA = GL.GL_SRC_ALPHA;
922
+ DST_ALPHA = GL.GL_DST_ALPHA;
923
+ ONE_MINUS_SRC_ALPHA = GL.GL_ONE_MINUS_SRC_ALPHA;
924
+ ONE_MINUS_DST_COLOR = GL.GL_ONE_MINUS_DST_COLOR;
925
+ ONE_MINUS_SRC_COLOR = GL.GL_ONE_MINUS_SRC_COLOR;
926
+ DST_COLOR = GL.GL_DST_COLOR;
927
+ SRC_COLOR = GL.GL_SRC_COLOR;
928
+
929
+ SAMPLE_ALPHA_TO_COVERAGE = GL.GL_SAMPLE_ALPHA_TO_COVERAGE;
930
+ SAMPLE_COVERAGE = GL.GL_SAMPLE_COVERAGE;
931
+
932
+ KEEP = GL.GL_KEEP;
933
+ REPLACE = GL.GL_REPLACE;
934
+ INCR = GL.GL_INCR;
935
+ DECR = GL.GL_DECR;
936
+ INVERT = GL.GL_INVERT;
937
+ INCR_WRAP = GL.GL_INCR_WRAP;
938
+ DECR_WRAP = GL.GL_DECR_WRAP;
939
+ NEVER = GL.GL_NEVER;
940
+ ALWAYS = GL.GL_ALWAYS;
941
+
942
+ EQUAL = GL.GL_EQUAL;
943
+ LESS = GL.GL_LESS;
944
+ LEQUAL = GL.GL_LEQUAL;
945
+ GREATER = GL.GL_GREATER;
946
+ GEQUAL = GL.GL_GEQUAL;
947
+ NOTEQUAL = GL.GL_NOTEQUAL;
948
+
949
+ FUNC_ADD = GL.GL_FUNC_ADD;
950
+ FUNC_MIN = GL2ES3.GL_MIN;
951
+ FUNC_MAX = GL2ES3.GL_MAX;
952
+ FUNC_REVERSE_SUBTRACT = GL.GL_FUNC_REVERSE_SUBTRACT;
953
+ FUNC_SUBTRACT = GL.GL_FUNC_SUBTRACT;
954
+
955
+ DITHER = GL.GL_DITHER;
956
+
957
+ CONSTANT_COLOR = GL2ES2.GL_CONSTANT_COLOR;
958
+ CONSTANT_ALPHA = GL2ES2.GL_CONSTANT_ALPHA;
959
+ ONE_MINUS_CONSTANT_COLOR = GL2ES2.GL_ONE_MINUS_CONSTANT_COLOR;
960
+ ONE_MINUS_CONSTANT_ALPHA = GL2ES2.GL_ONE_MINUS_CONSTANT_ALPHA;
961
+ SRC_ALPHA_SATURATE = GL.GL_SRC_ALPHA_SATURATE;
962
+
963
+ SCISSOR_TEST = GL.GL_SCISSOR_TEST;
964
+ STENCIL_TEST = GL.GL_STENCIL_TEST;
965
+ DEPTH_TEST = GL.GL_DEPTH_TEST;
966
+ DEPTH_WRITEMASK = GL.GL_DEPTH_WRITEMASK;
967
+
968
+ COLOR_BUFFER_BIT = GL.GL_COLOR_BUFFER_BIT;
969
+ DEPTH_BUFFER_BIT = GL.GL_DEPTH_BUFFER_BIT;
970
+ STENCIL_BUFFER_BIT = GL.GL_STENCIL_BUFFER_BIT;
971
+
972
+ FRAMEBUFFER = GL.GL_FRAMEBUFFER;
973
+ COLOR_ATTACHMENT0 = GL.GL_COLOR_ATTACHMENT0;
974
+ COLOR_ATTACHMENT1 = GL2ES2.GL_COLOR_ATTACHMENT1;
975
+ COLOR_ATTACHMENT2 = GL2ES2.GL_COLOR_ATTACHMENT2;
976
+ COLOR_ATTACHMENT3 = GL2ES2.GL_COLOR_ATTACHMENT3;
977
+ RENDERBUFFER = GL.GL_RENDERBUFFER;
978
+ DEPTH_ATTACHMENT = GL.GL_DEPTH_ATTACHMENT;
979
+ STENCIL_ATTACHMENT = GL.GL_STENCIL_ATTACHMENT;
980
+ READ_FRAMEBUFFER = GL.GL_READ_FRAMEBUFFER;
981
+ DRAW_FRAMEBUFFER = GL.GL_DRAW_FRAMEBUFFER;
982
+
983
+ RGBA8 = GL.GL_RGBA8;
984
+ DEPTH24_STENCIL8 = GL.GL_DEPTH24_STENCIL8;
985
+
986
+ DEPTH_COMPONENT = GL2ES2.GL_DEPTH_COMPONENT;
987
+ DEPTH_COMPONENT16 = GL.GL_DEPTH_COMPONENT16;
988
+ DEPTH_COMPONENT24 = GL.GL_DEPTH_COMPONENT24;
989
+ DEPTH_COMPONENT32 = GL.GL_DEPTH_COMPONENT32;
990
+
991
+ STENCIL_INDEX = GL2ES2.GL_STENCIL_INDEX;
992
+ STENCIL_INDEX1 = GL.GL_STENCIL_INDEX1;
993
+ STENCIL_INDEX4 = GL.GL_STENCIL_INDEX4;
994
+ STENCIL_INDEX8 = GL.GL_STENCIL_INDEX8;
995
+
996
+ DEPTH_STENCIL = GL.GL_DEPTH_STENCIL;
997
+
998
+ FRAMEBUFFER_COMPLETE = GL.GL_FRAMEBUFFER_COMPLETE;
999
+ FRAMEBUFFER_UNDEFINED = GL2ES3.GL_FRAMEBUFFER_UNDEFINED;
1000
+ FRAMEBUFFER_INCOMPLETE_ATTACHMENT = GL.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
1001
+ FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = GL.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
1002
+ FRAMEBUFFER_INCOMPLETE_DIMENSIONS = GL.GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
1003
+ FRAMEBUFFER_INCOMPLETE_FORMATS = GL.GL_FRAMEBUFFER_INCOMPLETE_FORMATS;
1004
+ FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER = GL2GL3.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER;
1005
+ FRAMEBUFFER_INCOMPLETE_READ_BUFFER = GL2GL3.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER;
1006
+ FRAMEBUFFER_UNSUPPORTED = GL.GL_FRAMEBUFFER_UNSUPPORTED;
1007
+ FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = GL.GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE;
1008
+ FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS = GL3ES3.GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS;
1009
+
1010
+ FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = GL.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE;
1011
+ FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = GL.GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME;
1012
+ FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = GL.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL;
1013
+ FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = GL.GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE;
1014
+
1015
+ RENDERBUFFER_WIDTH = GL.GL_RENDERBUFFER_WIDTH;
1016
+ RENDERBUFFER_HEIGHT = GL.GL_RENDERBUFFER_HEIGHT;
1017
+ RENDERBUFFER_RED_SIZE = GL.GL_RENDERBUFFER_RED_SIZE;
1018
+ RENDERBUFFER_GREEN_SIZE = GL.GL_RENDERBUFFER_GREEN_SIZE;
1019
+ RENDERBUFFER_BLUE_SIZE = GL.GL_RENDERBUFFER_BLUE_SIZE;
1020
+ RENDERBUFFER_ALPHA_SIZE = GL.GL_RENDERBUFFER_ALPHA_SIZE;
1021
+ RENDERBUFFER_DEPTH_SIZE = GL.GL_RENDERBUFFER_DEPTH_SIZE;
1022
+ RENDERBUFFER_STENCIL_SIZE = GL.GL_RENDERBUFFER_STENCIL_SIZE;
1023
+ RENDERBUFFER_INTERNAL_FORMAT = GL.GL_RENDERBUFFER_INTERNAL_FORMAT;
1024
+
1025
+ MULTISAMPLE = GL.GL_MULTISAMPLE;
1026
+ LINE_SMOOTH = GL.GL_LINE_SMOOTH;
1027
+ POLYGON_SMOOTH = GL2GL3.GL_POLYGON_SMOOTH;
1028
+
1029
+ SYNC_GPU_COMMANDS_COMPLETE = GL3ES3.GL_SYNC_GPU_COMMANDS_COMPLETE;
1030
+ ALREADY_SIGNALED = GL3ES3.GL_ALREADY_SIGNALED;
1031
+ CONDITION_SATISFIED = GL3ES3.GL_CONDITION_SATISFIED;
1032
+ }
1033
+
1034
+ ///////////////////////////////////////////////////////////
1035
+
1036
+ // Special Functions
1037
+
1038
+ @Override
1039
+ public void flush() {
1040
+ gl.glFlush();
1041
+ }
1042
+
1043
+ @Override
1044
+ public void finish() {
1045
+ gl.glFinish();
1046
+ }
1047
+
1048
+ @Override
1049
+ public void hint(int target, int hint) {
1050
+ gl.glHint(target, hint);
1051
+ }
1052
+
1053
+ ///////////////////////////////////////////////////////////
1054
+
1055
+ // State and State Requests
1056
+
1057
+ @Override
1058
+ public void enable(int value) {
1059
+ if (-1 < value) {
1060
+ gl.glEnable(value);
1061
+ }
1062
+ }
1063
+
1064
+ @Override
1065
+ public void disable(int value) {
1066
+ if (-1 < value) {
1067
+ gl.glDisable(value);
1068
+ }
1069
+ }
1070
+
1071
+ @Override
1072
+ public void getBooleanv(int value, IntBuffer data) {
1073
+ if (-1 < value) {
1074
+ if (byteBuffer.capacity() < data.capacity()) {
1075
+ byteBuffer = allocateDirectByteBuffer(data.capacity());
1076
+ }
1077
+ gl.glGetBooleanv(value, byteBuffer);
1078
+ for (int i = 0; i < data.capacity(); i++) {
1079
+ data.put(i, byteBuffer.get(i));
1080
+ }
1081
+ } else {
1082
+ fillIntBuffer(data, 0, data.capacity() - 1, 0);
1083
+ }
1084
+ }
1085
+
1086
+ @Override
1087
+ public void getIntegerv(int value, IntBuffer data) {
1088
+ if (-1 < value) {
1089
+ gl.glGetIntegerv(value, data);
1090
+ } else {
1091
+ fillIntBuffer(data, 0, data.capacity() - 1, 0);
1092
+ }
1093
+ }
1094
+
1095
+ @Override
1096
+ public void getFloatv(int value, FloatBuffer data) {
1097
+ if (-1 < value) {
1098
+ gl.glGetFloatv(value, data);
1099
+ } else {
1100
+ fillFloatBuffer(data, 0, data.capacity() - 1, 0);
1101
+ }
1102
+ }
1103
+
1104
+ @Override
1105
+ public boolean isEnabled(int value) {
1106
+ return gl.glIsEnabled(value);
1107
+ }
1108
+
1109
+ @Override
1110
+ public String getString(int name) {
1111
+ return gl.glGetString(name);
1112
+ }
1113
+
1114
+ ///////////////////////////////////////////////////////////
1115
+
1116
+ // Error Handling
1117
+
1118
+ @Override
1119
+ public int getError() {
1120
+ return gl.glGetError();
1121
+ }
1122
+
1123
+ @Override
1124
+ public String errorString(int err) {
1125
+ return glu.gluErrorString(err);
1126
+ }
1127
+
1128
+ //////////////////////////////////////////////////////////////////////////////
1129
+
1130
+ // Buffer Objects
1131
+
1132
+ @Override
1133
+ public void genBuffers(int n, IntBuffer buffers) {
1134
+ gl.glGenBuffers(n, buffers);
1135
+ }
1136
+
1137
+ @Override
1138
+ public void deleteBuffers(int n, IntBuffer buffers) {
1139
+ gl.glDeleteBuffers(n, buffers);
1140
+ }
1141
+
1142
+ @Override
1143
+ public void bindBuffer(int target, int buffer) {
1144
+ gl.glBindBuffer(target, buffer);
1145
+ }
1146
+
1147
+ @Override
1148
+ public void bufferData(int target, int size, Buffer data, int usage) {
1149
+ gl.glBufferData(target, size, data, usage);
1150
+ }
1151
+
1152
+ @Override
1153
+ public void bufferSubData(int target, int offset, int size, Buffer data) {
1154
+ gl.glBufferSubData(target, offset, size, data);
1155
+ }
1156
+
1157
+ @Override
1158
+ public void isBuffer(int buffer) {
1159
+ gl.glIsBuffer(buffer);
1160
+ }
1161
+
1162
+ @Override
1163
+ public void getBufferParameteriv(int target, int value, IntBuffer data) {
1164
+ gl.glGetBufferParameteriv(target, value, data);
1165
+ }
1166
+
1167
+ @Override
1168
+ public ByteBuffer mapBuffer(int target, int access) {
1169
+ return gl2.glMapBuffer(target, access);
1170
+ }
1171
+
1172
+ @Override
1173
+ public ByteBuffer mapBufferRange(int target, int offset, int length, int access) {
1174
+ if (gl2x != null) {
1175
+ return gl2x.glMapBufferRange(target, offset, length, access);
1176
+ } else if (gl3 != null) {
1177
+ return gl3.glMapBufferRange(target, offset, length, access);
1178
+ } else {
1179
+ throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glMapBufferRange()"));
1180
+ }
1181
+ }
1182
+
1183
+ @Override
1184
+ public void unmapBuffer(int target) {
1185
+ gl2.glUnmapBuffer(target);
1186
+ }
1187
+
1188
+ //////////////////////////////////////////////////////////////////////////////
1189
+
1190
+ // Synchronization
1191
+
1192
+ @Override
1193
+ public long fenceSync(int condition, int flags) {
1194
+ if (gl3es3 != null) {
1195
+ return gl3es3.glFenceSync(condition, flags);
1196
+ } else {
1197
+ throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "fenceSync()"));
1198
+ }
1199
+ }
1200
+
1201
+ @Override
1202
+ public void deleteSync(long sync) {
1203
+ if (gl3es3 != null) {
1204
+ gl3es3.glDeleteSync(sync);
1205
+ } else {
1206
+ throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "deleteSync()"));
1207
+ }
1208
+ }
1209
+
1210
+ @Override
1211
+ public int clientWaitSync(long sync, int flags, long timeout) {
1212
+ if (gl3es3 != null) {
1213
+ return gl3es3.glClientWaitSync(sync, flags, timeout);
1214
+ } else {
1215
+ throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "clientWaitSync()"));
1216
+ }
1217
+ }
1218
+
1219
+ //////////////////////////////////////////////////////////////////////////////
1220
+
1221
+ // Viewport and Clipping
1222
+
1223
+ @Override
1224
+ public void depthRangef(float n, float f) {
1225
+ gl.glDepthRangef(n, f);
1226
+ }
1227
+
1228
+ @Override
1229
+ public void viewport(int x, int y, int w, int h) {
1230
+ float scale = getPixelScale();
1231
+ viewportImpl((int)scale * x, (int)(scale * y), (int)(scale * w), (int)(scale * h));
1232
+ }
1233
+
1234
+ @Override
1235
+ protected void viewportImpl(int x, int y, int w, int h) {
1236
+ gl.glViewport(x, y, w, h);
1237
+ }
1238
+
1239
+ //////////////////////////////////////////////////////////////////////////////
1240
+
1241
+ // Reading Pixels
1242
+
1243
+ @Override
1244
+ protected void readPixelsImpl(int x, int y, int width, int height, int format, int type, Buffer buffer) {
1245
+ gl.glReadPixels(x, y, width, height, format, type, buffer);
1246
+ }
1247
+
1248
+ @Override
1249
+ protected void readPixelsImpl(int x, int y, int width, int height, int format, int type, long offset) {
1250
+ gl.glReadPixels(x, y, width, height, format, type, 0);
1251
+ }
1252
+
1253
+ //////////////////////////////////////////////////////////////////////////////
1254
+
1255
+ // Vertices
1256
+
1257
+ @Override
1258
+ public void vertexAttrib1f(int index, float value) {
1259
+ gl2.glVertexAttrib1f(index, value);
1260
+ }
1261
+
1262
+ @Override
1263
+ public void vertexAttrib2f(int index, float value0, float value1) {
1264
+ gl2.glVertexAttrib2f(index, value0, value1);
1265
+ }
1266
+
1267
+ @Override
1268
+ public void vertexAttrib3f(int index, float value0, float value1, float value2) {
1269
+ gl2.glVertexAttrib3f(index, value0, value1, value2);
1270
+ }
1271
+
1272
+ @Override
1273
+ public void vertexAttrib4f(int index, float value0, float value1, float value2, float value3) {
1274
+ gl2.glVertexAttrib4f(index, value0, value1, value2, value3);
1275
+ }
1276
+
1277
+ @Override
1278
+ public void vertexAttrib1fv(int index, FloatBuffer values) {
1279
+ gl2.glVertexAttrib1fv(index, values);
1280
+ }
1281
+
1282
+ @Override
1283
+ public void vertexAttrib2fv(int index, FloatBuffer values) {
1284
+ gl2.glVertexAttrib2fv(index, values);
1285
+ }
1286
+
1287
+ @Override
1288
+ public void vertexAttrib3fv(int index, FloatBuffer values) {
1289
+ gl2.glVertexAttrib3fv(index, values);
1290
+ }
1291
+
1292
+ @Override
1293
+ public void vertexAttrib4fv(int index, FloatBuffer values) {
1294
+ gl2.glVertexAttrib4fv(index, values);
1295
+ }
1296
+
1297
+ @Override
1298
+ public void vertexAttribPointer(int index, int size, int type, boolean normalized, int stride, int offset) {
1299
+ gl2.glVertexAttribPointer(index, size, type, normalized, stride, offset);
1300
+ }
1301
+
1302
+ @Override
1303
+ public void enableVertexAttribArray(int index) {
1304
+ gl2.glEnableVertexAttribArray(index);
1305
+ }
1306
+
1307
+ @Override
1308
+ public void disableVertexAttribArray(int index) {
1309
+ gl2.glDisableVertexAttribArray(index);
1310
+ }
1311
+
1312
+ @Override
1313
+ public void drawArraysImpl(int mode, int first, int count) {
1314
+ gl.glDrawArrays(mode, first, count);
1315
+ }
1316
+
1317
+ @Override
1318
+ public void drawElementsImpl(int mode, int count, int type, int offset) {
1319
+ gl.glDrawElements(mode, count, type, offset);
1320
+ }
1321
+
1322
+ //////////////////////////////////////////////////////////////////////////////
1323
+
1324
+ // Rasterization
1325
+
1326
+ @Override
1327
+ public void lineWidth(float width) {
1328
+ gl.glLineWidth(width);
1329
+ }
1330
+
1331
+ @Override
1332
+ public void frontFace(int dir) {
1333
+ gl.glFrontFace(dir);
1334
+ }
1335
+
1336
+ @Override
1337
+ public void cullFace(int mode) {
1338
+ gl.glCullFace(mode);
1339
+ }
1340
+
1341
+ @Override
1342
+ public void polygonOffset(float factor, float units) {
1343
+ gl.glPolygonOffset(factor, units);
1344
+ }
1345
+
1346
+ //////////////////////////////////////////////////////////////////////////////
1347
+
1348
+ // Pixel Rectangles
1349
+
1350
+ @Override
1351
+ public void pixelStorei(int pname, int param) {
1352
+ gl.glPixelStorei(pname, param);
1353
+ }
1354
+
1355
+ ///////////////////////////////////////////////////////////
1356
+
1357
+ // Texturing
1358
+
1359
+ @Override
1360
+ public void texImage2D(int target, int level, int internalFormat, int width, int height, int border, int format, int type, Buffer data) {
1361
+ gl.glTexImage2D(target, level, internalFormat, width, height, border, format, type, data);
1362
+ }
1363
+
1364
+ @Override
1365
+ public void copyTexImage2D(int target, int level, int internalFormat, int x, int y, int width, int height, int border) {
1366
+ gl.glCopyTexImage2D(target, level, internalFormat, x, y, width, height, border);
1367
+ }
1368
+
1369
+ @Override
1370
+ public void texSubImage2D(int target, int level, int xOffset, int yOffset, int width, int height, int format, int type, Buffer data) {
1371
+ gl.glTexSubImage2D(target, level, xOffset, yOffset, width, height, format, type, data);
1372
+ }
1373
+
1374
+ @Override
1375
+ public void copyTexSubImage2D(int target, int level, int xOffset, int yOffset, int x, int y, int width, int height) {
1376
+ gl.glCopyTexSubImage2D(target, level, x, y, xOffset, yOffset, width, height);
1377
+ }
1378
+
1379
+ @Override
1380
+ public void compressedTexImage2D(int target, int level, int internalFormat, int width, int height, int border, int imageSize, Buffer data) {
1381
+ gl.glCompressedTexImage2D(target, level, internalFormat, width, height, border, imageSize, data);
1382
+ }
1383
+
1384
+ @Override
1385
+ public void compressedTexSubImage2D(int target, int level, int xOffset, int yOffset, int width, int height, int format, int imageSize, Buffer data) {
1386
+ gl.glCompressedTexSubImage2D(target, level, xOffset, yOffset, width, height, format, imageSize, data);
1387
+ }
1388
+
1389
+ @Override
1390
+ public void texParameteri(int target, int pname, int param) {
1391
+ gl.glTexParameteri(target, pname, param);
1392
+ }
1393
+
1394
+ @Override
1395
+ public void texParameterf(int target, int pname, float param) {
1396
+ gl.glTexParameterf(target, pname, param);
1397
+ }
1398
+
1399
+ @Override
1400
+ public void texParameteriv(int target, int pname, IntBuffer params) {
1401
+ gl.glTexParameteriv(target, pname, params);
1402
+ }
1403
+
1404
+ @Override
1405
+ public void texParameterfv(int target, int pname, FloatBuffer params) {
1406
+ gl.glTexParameterfv(target, pname, params);
1407
+ }
1408
+
1409
+ @Override
1410
+ public void generateMipmap(int target) {
1411
+ gl.glGenerateMipmap(target);
1412
+ }
1413
+
1414
+ @Override
1415
+ public void genTextures(int n, IntBuffer textures) {
1416
+ gl.glGenTextures(n, textures);
1417
+ }
1418
+
1419
+ @Override
1420
+ public void deleteTextures(int n, IntBuffer textures) {
1421
+ gl.glDeleteTextures(n, textures);
1422
+ }
1423
+
1424
+ @Override
1425
+ public void getTexParameteriv(int target, int pname, IntBuffer params) {
1426
+ gl.glGetTexParameteriv(target, pname, params);
1427
+ }
1428
+
1429
+ @Override
1430
+ public void getTexParameterfv(int target, int pname, FloatBuffer params) {
1431
+ gl.glGetTexParameterfv(target, pname, params);
1432
+ }
1433
+
1434
+ @Override
1435
+ public boolean isTexture(int texture) {
1436
+ return gl.glIsTexture(texture);
1437
+ }
1438
+
1439
+ @Override
1440
+ protected void activeTextureImpl(int texture) {
1441
+ gl.glActiveTexture(texture);
1442
+ }
1443
+
1444
+ @Override
1445
+ protected void bindTextureImpl(int target, int texture) {
1446
+ gl.glBindTexture(target, texture);
1447
+ }
1448
+
1449
+ ///////////////////////////////////////////////////////////
1450
+
1451
+ // Shaders and Programs
1452
+
1453
+ @Override
1454
+ public int createShader(int type) {
1455
+ return gl2.glCreateShader(type);
1456
+ }
1457
+
1458
+ @Override
1459
+ public void shaderSource(int shader, String source) {
1460
+ gl2.glShaderSource(shader, 1, new String[] { source }, (int[]) null, 0);
1461
+ }
1462
+
1463
+ @Override
1464
+ public void compileShader(int shader) {
1465
+ gl2.glCompileShader(shader);
1466
+ }
1467
+
1468
+ @Override
1469
+ public void releaseShaderCompiler() {
1470
+ gl2.glReleaseShaderCompiler();
1471
+ }
1472
+
1473
+ @Override
1474
+ public void deleteShader(int shader) {
1475
+ gl2.glDeleteShader(shader);
1476
+ }
1477
+
1478
+ @Override
1479
+ public void shaderBinary(int count, IntBuffer shaders, int binaryFormat, Buffer binary, int length) {
1480
+ gl2.glShaderBinary(count, shaders, binaryFormat, binary, length);
1481
+ }
1482
+
1483
+ @Override
1484
+ public int createProgram() {
1485
+ return gl2.glCreateProgram();
1486
+ }
1487
+
1488
+ @Override
1489
+ public void attachShader(int program, int shader) {
1490
+ gl2.glAttachShader(program, shader);
1491
+ }
1492
+
1493
+ @Override
1494
+ public void detachShader(int program, int shader) {
1495
+ gl2.glDetachShader(program, shader);
1496
+ }
1497
+
1498
+ @Override
1499
+ public void linkProgram(int program) {
1500
+ gl2.glLinkProgram(program);
1501
+ }
1502
+
1503
+ @Override
1504
+ public void useProgram(int program) {
1505
+ gl2.glUseProgram(program);
1506
+ }
1507
+
1508
+ @Override
1509
+ public void deleteProgram(int program) {
1510
+ gl2.glDeleteProgram(program);
1511
+ }
1512
+
1513
+ @Override
1514
+ public String getActiveAttrib(int program, int index, IntBuffer size, IntBuffer type) {
1515
+ int[] tmp = {0, 0, 0};
1516
+ byte[] namebuf = new byte[1024];
1517
+ gl2.glGetActiveAttrib(program, index, 1024, tmp, 0, tmp, 1, tmp, 2, namebuf, 0);
1518
+ size.put(tmp[1]);
1519
+ type.put(tmp[2]);
1520
+ String name = new String(namebuf, 0, tmp[0]);
1521
+ return name;
1522
+ }
1523
+
1524
+ @Override
1525
+ public int getAttribLocation(int program, String name) {
1526
+ return gl2.glGetAttribLocation(program, name);
1527
+ }
1528
+
1529
+ @Override
1530
+ public void bindAttribLocation(int program, int index, String name) {
1531
+ gl2.glBindAttribLocation(program, index, name);
1532
+ }
1533
+
1534
+ @Override
1535
+ public int getUniformLocation(int program, String name) {
1536
+ return gl2.glGetUniformLocation(program, name);
1537
+ }
1538
+
1539
+ @Override
1540
+ public String getActiveUniform(int program, int index, IntBuffer size, IntBuffer type) {
1541
+ int[] tmp= {0, 0, 0};
1542
+ byte[] namebuf = new byte[1024];
1543
+ gl2.glGetActiveUniform(program, index, 1024, tmp, 0, tmp, 1, tmp, 2, namebuf, 0);
1544
+ size.put(tmp[1]);
1545
+ type.put(tmp[2]);
1546
+ String name = new String(namebuf, 0, tmp[0]);
1547
+ return name;
1548
+ }
1549
+
1550
+ @Override
1551
+ public void uniform1i(int location, int value) {
1552
+ gl2.glUniform1i(location, value);
1553
+ }
1554
+
1555
+ @Override
1556
+ public void uniform2i(int location, int value0, int value1) {
1557
+ gl2.glUniform2i(location, value0, value1);
1558
+ }
1559
+
1560
+ @Override
1561
+ public void uniform3i(int location, int value0, int value1, int value2) {
1562
+ gl2.glUniform3i(location, value0, value1, value2);
1563
+ }
1564
+
1565
+ @Override
1566
+ public void uniform4i(int location, int value0, int value1, int value2, int value3) {
1567
+ gl2.glUniform4i(location, value0, value1, value2, value3);
1568
+ }
1569
+
1570
+ @Override
1571
+ public void uniform1f(int location, float value) {
1572
+ gl2.glUniform1f(location, value);
1573
+ }
1574
+
1575
+ @Override
1576
+ public void uniform2f(int location, float value0, float value1) {
1577
+ gl2.glUniform2f(location, value0, value1);
1578
+ }
1579
+
1580
+ @Override
1581
+ public void uniform3f(int location, float value0, float value1, float value2) {
1582
+ gl2.glUniform3f(location, value0, value1, value2);
1583
+ }
1584
+
1585
+ @Override
1586
+ public void uniform4f(int location, float value0, float value1, float value2, float value3) {
1587
+ gl2.glUniform4f(location, value0, value1, value2, value3);
1588
+ }
1589
+
1590
+ @Override
1591
+ public void uniform1iv(int location, int count, IntBuffer v) {
1592
+ gl2.glUniform1iv(location, count, v);
1593
+ }
1594
+
1595
+ @Override
1596
+ public void uniform2iv(int location, int count, IntBuffer v) {
1597
+ gl2.glUniform2iv(location, count, v);
1598
+ }
1599
+
1600
+ @Override
1601
+ public void uniform3iv(int location, int count, IntBuffer v) {
1602
+ gl2.glUniform3iv(location, count, v);
1603
+ }
1604
+
1605
+ @Override
1606
+ public void uniform4iv(int location, int count, IntBuffer v) {
1607
+ gl2.glUniform4iv(location, count, v);
1608
+ }
1609
+
1610
+ @Override
1611
+ public void uniform1fv(int location, int count, FloatBuffer v) {
1612
+ gl2.glUniform1fv(location, count, v);
1613
+ }
1614
+
1615
+ @Override
1616
+ public void uniform2fv(int location, int count, FloatBuffer v) {
1617
+ gl2.glUniform2fv(location, count, v);
1618
+ }
1619
+
1620
+ @Override
1621
+ public void uniform3fv(int location, int count, FloatBuffer v) {
1622
+ gl2.glUniform3fv(location, count, v);
1623
+ }
1624
+
1625
+ @Override
1626
+ public void uniform4fv(int location, int count, FloatBuffer v) {
1627
+ gl2.glUniform4fv(location, count, v);
1628
+ }
1629
+
1630
+ @Override
1631
+ public void uniformMatrix2fv(int location, int count, boolean transpose, FloatBuffer mat) {
1632
+ gl2.glUniformMatrix2fv(location, count, transpose, mat);
1633
+ }
1634
+
1635
+ @Override
1636
+ public void uniformMatrix3fv(int location, int count, boolean transpose, FloatBuffer mat) {
1637
+ gl2.glUniformMatrix3fv(location, count, transpose, mat);
1638
+ }
1639
+
1640
+ @Override
1641
+ public void uniformMatrix4fv(int location, int count, boolean transpose, FloatBuffer mat) {
1642
+ gl2.glUniformMatrix4fv(location, count, transpose, mat);
1643
+ }
1644
+
1645
+ @Override
1646
+ public void validateProgram(int program) {
1647
+ gl2.glValidateProgram(program);
1648
+ }
1649
+
1650
+ @Override
1651
+ public boolean isShader(int shader) {
1652
+ return gl2.glIsShader(shader);
1653
+ }
1654
+
1655
+ @Override
1656
+ public void getShaderiv(int shader, int pname, IntBuffer params) {
1657
+ gl2.glGetShaderiv(shader, pname, params);
1658
+ }
1659
+
1660
+ @Override
1661
+ public void getAttachedShaders(int program, int maxCount, IntBuffer count, IntBuffer shaders) {
1662
+ gl2.glGetAttachedShaders(program, maxCount, count, shaders);
1663
+ }
1664
+
1665
+ @Override
1666
+ public String getShaderInfoLog(int shader) {
1667
+ int[] val = { 0 };
1668
+ gl2.glGetShaderiv(shader, GL2ES2.GL_INFO_LOG_LENGTH, val, 0);
1669
+ int length = val[0];
1670
+
1671
+ byte[] log = new byte[length];
1672
+ gl2.glGetShaderInfoLog(shader, length, val, 0, log, 0);
1673
+ return new String(log);
1674
+ }
1675
+
1676
+ @Override
1677
+ public String getShaderSource(int shader) {
1678
+ int[] len = {0};
1679
+ byte[] buf = new byte[1024];
1680
+ gl2.glGetShaderSource(shader, 1024, len, 0, buf, 0);
1681
+ return new String(buf, 0, len[0]);
1682
+ }
1683
+
1684
+ @Override
1685
+ public void getShaderPrecisionFormat(int shaderType, int precisionType, IntBuffer range, IntBuffer precision) {
1686
+ gl2.glGetShaderPrecisionFormat(shaderType, precisionType, range, precision);
1687
+ }
1688
+
1689
+ @Override
1690
+ public void getVertexAttribfv(int index, int pname, FloatBuffer params) {
1691
+ gl2.glGetVertexAttribfv(index, pname, params);
1692
+ }
1693
+
1694
+ @Override
1695
+ public void getVertexAttribiv(int index, int pname, IntBuffer params) {
1696
+ gl2.glGetVertexAttribiv(index, pname, params);
1697
+ }
1698
+
1699
+ @Override
1700
+ public void getVertexAttribPointerv(int index, int pname, ByteBuffer data) {
1701
+ throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glGetVertexAttribPointerv()"));
1702
+ }
1703
+
1704
+ @Override
1705
+ public void getUniformfv(int program, int location, FloatBuffer params) {
1706
+ gl2.glGetUniformfv(program, location, params);
1707
+ }
1708
+
1709
+ @Override
1710
+ public void getUniformiv(int program, int location, IntBuffer params) {
1711
+ gl2.glGetUniformiv(program, location, params);
1712
+ }
1713
+
1714
+ @Override
1715
+ public boolean isProgram(int program) {
1716
+ return gl2.glIsProgram(program);
1717
+ }
1718
+
1719
+ @Override
1720
+ public void getProgramiv(int program, int pname, IntBuffer params) {
1721
+ gl2.glGetProgramiv(program, pname, params);
1722
+ }
1723
+
1724
+ @Override
1725
+ public String getProgramInfoLog(int program) {
1726
+ int[] val = { 0 };
1727
+ gl2.glGetProgramiv(program, GL2ES2.GL_INFO_LOG_LENGTH, val, 0);
1728
+ int length = val[0];
1729
+
1730
+ if (0 < length) {
1731
+ byte[] log = new byte[length];
1732
+ gl2.glGetProgramInfoLog(program, length, val, 0, log, 0);
1733
+ return new String(log);
1734
+ } else {
1735
+ return "Unknown error";
1736
+ }
1737
+ }
1738
+
1739
+ ///////////////////////////////////////////////////////////
1740
+
1741
+ // Per-Fragment Operations
1742
+
1743
+ @Override
1744
+ public void scissor(int x, int y, int w, int h) {
1745
+ float scale = getPixelScale();
1746
+ gl.glScissor((int)scale * x, (int)(scale * y), (int)(scale * w), (int)(scale * h));
1747
+ // gl.glScissor(x, y, w, h);
1748
+ }
1749
+
1750
+ @Override
1751
+ public void sampleCoverage(float value, boolean invert) {
1752
+ gl2.glSampleCoverage(value, invert);
1753
+ }
1754
+
1755
+ @Override
1756
+ public void stencilFunc(int func, int ref, int mask) {
1757
+ gl2.glStencilFunc(func, ref, mask);
1758
+ }
1759
+
1760
+ @Override
1761
+ public void stencilFuncSeparate(int face, int func, int ref, int mask) {
1762
+ gl2.glStencilFuncSeparate(face, func, ref, mask);
1763
+ }
1764
+
1765
+ @Override
1766
+ public void stencilOp(int sfail, int dpfail, int dppass) {
1767
+ gl2.glStencilOp(sfail, dpfail, dppass);
1768
+ }
1769
+
1770
+ @Override
1771
+ public void stencilOpSeparate(int face, int sfail, int dpfail, int dppass) {
1772
+ gl2.glStencilOpSeparate(face, sfail, dpfail, dppass);
1773
+ }
1774
+
1775
+ @Override
1776
+ public void depthFunc(int func) {
1777
+ gl.glDepthFunc(func);
1778
+ }
1779
+
1780
+ @Override
1781
+ public void blendEquation(int mode) {
1782
+ gl.glBlendEquation(mode);
1783
+ }
1784
+
1785
+ @Override
1786
+ public void blendEquationSeparate(int modeRGB, int modeAlpha) {
1787
+ gl.glBlendEquationSeparate(modeRGB, modeAlpha);
1788
+ }
1789
+
1790
+ @Override
1791
+ public void blendFunc(int src, int dst) {
1792
+ gl.glBlendFunc(src, dst);
1793
+ }
1794
+
1795
+ @Override
1796
+ public void blendFuncSeparate(int srcRGB, int dstRGB, int srcAlpha, int dstAlpha) {
1797
+ gl.glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
1798
+ }
1799
+
1800
+ @Override
1801
+ public void blendColor(float red, float green, float blue, float alpha) {
1802
+ gl2.glBlendColor(red, green, blue, alpha);
1803
+ }
1804
+
1805
+ ///////////////////////////////////////////////////////////
1806
+
1807
+ // Whole Framebuffer Operations
1808
+
1809
+ @Override
1810
+ public void colorMask(boolean r, boolean g, boolean b, boolean a) {
1811
+ gl.glColorMask(r, g, b, a);
1812
+ }
1813
+
1814
+ @Override
1815
+ public void depthMask(boolean mask) {
1816
+ gl.glDepthMask(mask);
1817
+ }
1818
+
1819
+ @Override
1820
+ public void stencilMask(int mask) {
1821
+ gl.glStencilMask(mask);
1822
+ }
1823
+
1824
+ @Override
1825
+ public void stencilMaskSeparate(int face, int mask) {
1826
+ gl2.glStencilMaskSeparate(face, mask);
1827
+ }
1828
+
1829
+ @Override
1830
+ public void clearColor(float r, float g, float b, float a) {
1831
+ gl.glClearColor(r, g, b, a);
1832
+ }
1833
+
1834
+ @Override
1835
+ public void clearDepth(float d) {
1836
+ gl.glClearDepth(d);
1837
+ }
1838
+
1839
+ @Override
1840
+ public void clearStencil(int s) {
1841
+ gl.glClearStencil(s);
1842
+ }
1843
+
1844
+ @Override
1845
+ public void clear(int buf) {
1846
+ gl.glClear(buf);
1847
+ }
1848
+
1849
+ ///////////////////////////////////////////////////////////
1850
+
1851
+ // Framebuffers Objects
1852
+
1853
+ @Override
1854
+ protected void bindFramebufferImpl(int target, int framebuffer) {
1855
+ gl.glBindFramebuffer(target, framebuffer);
1856
+ }
1857
+
1858
+ @Override
1859
+ public void deleteFramebuffers(int n, IntBuffer framebuffers) {
1860
+ gl.glDeleteFramebuffers(n, framebuffers);
1861
+ }
1862
+
1863
+ @Override
1864
+ public void genFramebuffers(int n, IntBuffer framebuffers) {
1865
+ gl.glGenFramebuffers(n, framebuffers);
1866
+ }
1867
+
1868
+ @Override
1869
+ public void bindRenderbuffer(int target, int renderbuffer) {
1870
+ gl.glBindRenderbuffer(target, renderbuffer);
1871
+ }
1872
+
1873
+ @Override
1874
+ public void deleteRenderbuffers(int n, IntBuffer renderbuffers) {
1875
+ gl.glDeleteRenderbuffers(n, renderbuffers);
1876
+ }
1877
+
1878
+ @Override
1879
+ public void genRenderbuffers(int n, IntBuffer renderbuffers) {
1880
+ gl.glGenRenderbuffers(n, renderbuffers);
1881
+ }
1882
+
1883
+ @Override
1884
+ public void renderbufferStorage(int target, int internalFormat, int width, int height) {
1885
+ gl.glRenderbufferStorage(target, internalFormat, width, height);
1886
+ }
1887
+
1888
+ @Override
1889
+ public void framebufferRenderbuffer(int target, int attachment, int rendbuferfTarget, int renderbuffer) {
1890
+ gl.glFramebufferRenderbuffer(target, attachment, rendbuferfTarget, renderbuffer);
1891
+ }
1892
+
1893
+ @Override
1894
+ public void framebufferTexture2D(int target, int attachment, int texTarget, int texture, int level) {
1895
+ gl.glFramebufferTexture2D(target, attachment, texTarget, texture, level);
1896
+ }
1897
+
1898
+ @Override
1899
+ public int checkFramebufferStatus(int target) {
1900
+ return gl.glCheckFramebufferStatus(target);
1901
+ }
1902
+
1903
+ @Override
1904
+ public boolean isFramebuffer(int framebuffer) {
1905
+ return gl2.glIsFramebuffer(framebuffer);
1906
+ }
1907
+
1908
+ @Override
1909
+ public void getFramebufferAttachmentParameteriv(int target, int attachment, int pname, IntBuffer params) {
1910
+ gl2.glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
1911
+ }
1912
+
1913
+ @Override
1914
+ public boolean isRenderbuffer(int renderbuffer) {
1915
+ return gl2.glIsRenderbuffer(renderbuffer);
1916
+ }
1917
+
1918
+ @Override
1919
+ public void getRenderbufferParameteriv(int target, int pname, IntBuffer params) {
1920
+ gl2.glGetRenderbufferParameteriv(target, pname, params);
1921
+ }
1922
+
1923
+ @Override
1924
+ public void blitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, int mask, int filter) {
1925
+ if (gl2x != null) {
1926
+ gl2x.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
1927
+ } else if (gl3 != null) {
1928
+ gl3.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
1929
+ } else {
1930
+ throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glBlitFramebuffer()"));
1931
+ }
1932
+ }
1933
+
1934
+ @Override
1935
+ public void renderbufferStorageMultisample(int target, int samples, int format, int width, int height) {
1936
+ if (gl2x != null) {
1937
+ gl2x.glRenderbufferStorageMultisample(target, samples, format, width, height);
1938
+ } else if (gl3 != null) {
1939
+ gl3.glRenderbufferStorageMultisample(target, samples, format, width, height);
1940
+ } else {
1941
+ throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glRenderbufferStorageMultisample()"));
1942
+ }
1943
+ }
1944
+
1945
+ @Override
1946
+ public void readBuffer(int buf) {
1947
+ if (gl2x != null) {
1948
+ gl2x.glReadBuffer(buf);
1949
+ } else if (gl3 != null) {
1950
+ gl3.glReadBuffer(buf);
1951
+ } else {
1952
+ throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glReadBuffer()"));
1953
+ }
1954
+ }
1955
+
1956
+ @Override
1957
+ public void drawBuffer(int buf) {
1958
+ if (gl2x != null) {
1959
+ gl2x.glDrawBuffer(buf);
1960
+ } else if (gl3 != null) {
1961
+ gl3.glDrawBuffer(buf);
1962
+ } else {
1963
+ throw new RuntimeException(String.format(MISSING_GLFUNC_ERROR, "glDrawBuffer()"));
1964
+ }
1965
+ }
1966
+ }