propane 3.4.2-java → 3.5.0-java

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