picrate 0.7.0-java → 0.8.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.mvn/wrapper/MavenWrapperDownloader.java +117 -0
  4. data/.mvn/wrapper/maven-wrapper.properties +2 -1
  5. data/.travis.yml +2 -5
  6. data/CHANGELOG.md +4 -0
  7. data/README.md +3 -3
  8. data/Rakefile +15 -27
  9. data/docs/_config.yml +1 -1
  10. data/docs/_posts/2018-05-11-arch-linux-arm.md +1 -1
  11. data/docs/_posts/2018-11-18-building-gem.md +1 -1
  12. data/lib/picrate/app.rb +1 -1
  13. data/lib/picrate/native_folder.rb +1 -1
  14. data/lib/picrate/version.rb +1 -1
  15. data/mvnw +127 -51
  16. data/mvnw.cmd +182 -0
  17. data/pom.rb +39 -30
  18. data/pom.xml +50 -37
  19. data/src/main/java/monkstone/ColorUtil.java +1 -1
  20. data/src/main/java/monkstone/core/LibraryProxy.java +0 -1
  21. data/src/main/java/monkstone/noise/SimplexNoise.java +1 -1
  22. data/src/main/java/monkstone/vecmath/GfxRender.java +87 -0
  23. data/src/main/java/monkstone/vecmath/ShapeRender.java +1 -1
  24. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +1 -1
  25. data/src/main/java/processing/awt/PGraphicsJava2D.java +48 -50
  26. data/src/main/java/processing/awt/PShapeJava2D.java +10 -0
  27. data/src/main/java/processing/awt/PSurfaceAWT.java +315 -371
  28. data/src/main/java/processing/core/PApplet.java +15424 -15495
  29. data/src/main/java/processing/core/PConstants.java +4 -4
  30. data/src/main/java/processing/core/PFont.java +394 -369
  31. data/src/main/java/processing/core/PGraphics.java +11 -10
  32. data/src/main/java/processing/core/PImage.java +1389 -1435
  33. data/src/main/java/processing/core/PMatrix2D.java +297 -294
  34. data/src/main/java/processing/core/PMatrix3D.java +641 -594
  35. data/src/main/java/processing/core/PShape.java +1755 -1784
  36. data/src/main/java/processing/core/PShapeOBJ.java +145 -133
  37. data/src/main/java/processing/core/PShapeSVG.java +808 -801
  38. data/src/main/java/processing/core/PStyle.java +141 -149
  39. data/src/main/java/processing/core/PSurface.java +111 -117
  40. data/src/main/java/processing/core/PSurfaceNone.java +178 -187
  41. data/src/main/java/processing/javafx/PGraphicsFX2D.java +349 -346
  42. data/src/main/java/processing/opengl/FontTexture.java +40 -59
  43. data/src/main/java/processing/opengl/FrameBuffer.java +28 -18
  44. data/src/main/java/processing/opengl/LinePath.java +7 -7
  45. data/src/main/java/processing/opengl/LineStroker.java +6 -10
  46. data/src/main/java/processing/opengl/PGL.java +56 -44
  47. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +909 -2338
  48. data/src/main/java/processing/opengl/PJOGL.java +1722 -1763
  49. data/src/main/java/processing/opengl/PShader.java +1308 -1192
  50. data/src/main/java/processing/opengl/PShapeOpenGL.java +487 -1811
  51. data/src/main/java/processing/opengl/PSurfaceJOGL.java +482 -497
  52. data/src/main/java/processing/opengl/Texture.java +99 -76
  53. data/src/main/java/processing/opengl/VertexBuffer.java +41 -43
  54. data/vendors/Rakefile +1 -1
  55. metadata +7 -4
@@ -1,6 +1,6 @@
1
1
  /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
2
 
3
- /*
3
+ /*
4
4
  Part of the Processing project - http://processing.org
5
5
 
6
6
  Copyright (c) 2012-15 The Processing Foundation
@@ -20,8 +20,7 @@
20
20
  Public License along with this library; if not, write to the
21
21
  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22
22
  Boston, MA 02111-1307 USA
23
- */
24
-
23
+ */
25
24
  package processing.opengl;
26
25
 
27
26
  import processing.core.PApplet;
@@ -33,22 +32,21 @@ import processing.core.PImage;
33
32
  import java.util.HashMap;
34
33
 
35
34
  /**
36
- * All the infrastructure needed for optimized font rendering
37
- * in OpenGL. Basically, this special class is needed because
38
- * fonts in Processing are handled by a separate PImage for each
39
- * glyph. For performance reasons, all these glyphs should be
40
- * stored in a single OpenGL texture (otherwise, rendering a
41
- * string of text would involve binding and un-binding several
42
- * textures.
43
- * PFontTexture manages the correspondence between individual
44
- * glyphs and the large OpenGL texture containing them. Also,
45
- * in the case that the font size is very large, one single
46
- * OpenGL texture might not be enough to store all the glyphs,
47
- * so PFontTexture also takes care of spreading a single font
35
+ * All the infrastructure needed for optimized font rendering in OpenGL.
36
+ * Basically, this special class is needed because fonts in Processing are
37
+ * handled by a separate PImage for each glyph. For performance reasons, all
38
+ * these glyphs should be stored in a single OpenGL texture (otherwise,
39
+ * rendering a string of text would involve binding and un-binding several
40
+ * textures. PFontTexture manages the correspondence between individual glyphs
41
+ * and the large OpenGL texture containing them. Also, in the case that the font
42
+ * size is very large, one single OpenGL texture might not be enough to store
43
+ * all the glyphs, so PFontTexture also takes care of spreading a single font
48
44
  * over several textures.
45
+ *
49
46
  * @author Andres Colubri
50
47
  */
51
48
  class FontTexture implements PConstants {
49
+
52
50
  protected PGL pgl;
53
51
  protected boolean is3D;
54
52
 
@@ -70,32 +68,29 @@ class FontTexture implements PConstants {
70
68
  initTexture(pg, font);
71
69
  }
72
70
 
73
-
74
71
  protected void allocate() {
75
72
  // Nothing to do here: the font textures will allocate
76
73
  // themselves.
77
74
  }
78
75
 
79
-
80
76
  protected void dispose() {
81
- for (int i = 0; i < textures.length; i++) {
82
- textures[i].dispose();
77
+ for (Texture texture : textures) {
78
+ texture.dispose();
83
79
  }
84
80
  }
85
81
 
86
-
87
- protected void initTexture(PGraphicsOpenGL pg, PFont font) {
82
+ protected final void initTexture(PGraphicsOpenGL pg, PFont font) {
88
83
  lastTex = -1;
89
84
 
90
85
  int spow = PGL.nextPowerOfTwo(font.getSize());
91
86
  minSize = PApplet.min(PGraphicsOpenGL.maxTextureSize,
92
- PApplet.max(PGL.MIN_FONT_TEX_SIZE, spow));
87
+ PApplet.max(PGL.MIN_FONT_TEX_SIZE, spow));
93
88
  maxSize = PApplet.min(PGraphicsOpenGL.maxTextureSize,
94
- PApplet.max(PGL.MAX_FONT_TEX_SIZE, 2 * spow));
89
+ PApplet.max(PGL.MAX_FONT_TEX_SIZE, 2 * spow));
95
90
 
96
91
  if (maxSize < spow) {
97
- PGraphics.showWarning("The font size is too large to be properly " +
98
- "displayed with OpenGL");
92
+ PGraphics.showWarning("The font size is too large to be properly "
93
+ + "displayed with OpenGL");
99
94
  }
100
95
 
101
96
  addTexture(pg);
@@ -104,12 +99,11 @@ class FontTexture implements PConstants {
104
99
  offsetY = 0;
105
100
  lineHeight = 0;
106
101
 
107
- texinfoMap = new HashMap<PFont.Glyph, TextureInfo>();
102
+ texinfoMap = new HashMap<>();
108
103
  glyphTexinfos = new TextureInfo[font.getGlyphCount()];
109
104
  addAllGlyphsToTexture(pg, font);
110
105
  }
111
106
 
112
-
113
107
  public boolean addTexture(PGraphicsOpenGL pg) {
114
108
  int w, h;
115
109
  boolean resize;
@@ -130,14 +124,14 @@ class FontTexture implements PConstants {
130
124
  // Bilinear sampling ensures that the texture doesn't look pixelated
131
125
  // either when it is magnified or minified...
132
126
  tex = new Texture(pg, w, h,
133
- new Texture.Parameters(ARGB, Texture.BILINEAR, false));
127
+ new Texture.Parameters(ARGB, Texture.BILINEAR, false));
134
128
  } else {
135
129
  // ...however, the effect of bilinear sampling is to add some blurriness
136
130
  // to the text in its original size. In 2D, we assume that text will be
137
131
  // shown at its original size, so linear sampling is chosen instead (which
138
132
  // only affects minimized text).
139
133
  tex = new Texture(pg, w, h,
140
- new Texture.Parameters(ARGB, Texture.LINEAR, false));
134
+ new Texture.Parameters(ARGB, Texture.LINEAR, false));
141
135
  }
142
136
 
143
137
  if (textures == null) {
@@ -177,23 +171,19 @@ class FontTexture implements PConstants {
177
171
  return resize;
178
172
  }
179
173
 
180
-
181
174
  public void begin() {
182
175
  }
183
176
 
184
-
185
177
  public void end() {
186
- for (int i = 0; i < textures.length; i++) {
187
- pgl.disableTexturing(textures[i].glTarget);
178
+ for (Texture texture : textures) {
179
+ pgl.disableTexturing(texture.glTarget);
188
180
  }
189
181
  }
190
182
 
191
-
192
183
  public PImage getTexture(TextureInfo info) {
193
184
  return images[info.texIndex];
194
185
  }
195
186
 
196
-
197
187
  // Add all the current glyphs to opengl texture.
198
188
  public void addAllGlyphsToTexture(PGraphicsOpenGL pg, PFont font) {
199
189
  // loop over current glyphs.
@@ -202,24 +192,20 @@ class FontTexture implements PConstants {
202
192
  }
203
193
  }
204
194
 
205
-
206
195
  public void updateGlyphsTexCoords() {
207
196
  // loop over current glyphs.
208
- for (int i = 0; i < glyphTexinfos.length; i++) {
209
- TextureInfo tinfo = glyphTexinfos[i];
197
+ for (TextureInfo tinfo : glyphTexinfos) {
210
198
  if (tinfo != null && tinfo.texIndex == lastTex) {
211
199
  tinfo.updateUV();
212
200
  }
213
201
  }
214
202
  }
215
203
 
216
-
217
204
  public TextureInfo getTexInfo(PFont.Glyph glyph) {
218
205
  TextureInfo info = texinfoMap.get(glyph);
219
206
  return info;
220
207
  }
221
208
 
222
-
223
209
  public TextureInfo addToTexture(PGraphicsOpenGL pg, PFont.Glyph glyph) {
224
210
  int n = glyphTexinfos.length;
225
211
  if (n == 0) {
@@ -229,17 +215,16 @@ class FontTexture implements PConstants {
229
215
  return glyphTexinfos[n];
230
216
  }
231
217
 
232
-
233
218
  public boolean contextIsOutdated() {
234
219
  boolean outdated = false;
235
- for (int i = 0; i < textures.length; i++) {
236
- if (textures[i].contextIsOutdated()) {
220
+ for (Texture texture : textures) {
221
+ if (texture.contextIsOutdated()) {
237
222
  outdated = true;
238
223
  }
239
224
  }
240
225
  if (outdated) {
241
- for (int i = 0; i < textures.length; i++) {
242
- textures[i].dispose();
226
+ for (Texture texture : textures) {
227
+ texture.dispose();
243
228
  }
244
229
  }
245
230
  return outdated;
@@ -251,8 +236,6 @@ class FontTexture implements PConstants {
251
236
  // tex.glWidth, tex.glHeight,
252
237
  // 0, 0, tex.glWidth, tex.glHeight);
253
238
  // }
254
-
255
-
256
239
  // Adds this glyph to the opengl texture in PFont.
257
240
  protected void addToTexture(PGraphicsOpenGL pg, int idx, PFont.Glyph glyph) {
258
241
  // We add one pixel to avoid issues when sampling the font texture at
@@ -271,7 +254,7 @@ class FontTexture implements PConstants {
271
254
  int[] rgba = new int[w * h];
272
255
  int t = 0;
273
256
  int p = 0;
274
- if (PGL.BIG_ENDIAN) {
257
+ if (PGL.BIG_ENDIAN) {
275
258
  java.util.Arrays.fill(rgba, 0, w, 0xFFFFFF00); // Set the first row to blank pixels.
276
259
  t = w;
277
260
  for (int y = 0; y < glyph.height; y++) {
@@ -333,8 +316,8 @@ class FontTexture implements PConstants {
333
316
  texinfoMap.put(glyph, tinfo);
334
317
  }
335
318
 
336
-
337
319
  class TextureInfo {
320
+
338
321
  int texIndex;
339
322
  int width;
340
323
  int height;
@@ -344,7 +327,7 @@ class FontTexture implements PConstants {
344
327
  int[] pixels;
345
328
 
346
329
  TextureInfo(int tidx, int cropX, int cropY, int cropW, int cropH,
347
- int[] pix) {
330
+ int[] pix) {
348
331
  texIndex = tidx;
349
332
  crop = new int[4];
350
333
  // The region of the texture corresponding to the glyph is surrounded by a
@@ -359,21 +342,19 @@ class FontTexture implements PConstants {
359
342
  updateTex();
360
343
  }
361
344
 
362
-
363
- void updateUV() {
345
+ final void updateUV() {
364
346
  width = textures[texIndex].glWidth;
365
347
  height = textures[texIndex].glHeight;
366
348
 
367
- u0 = (float)crop[0] / (float)width;
368
- u1 = u0 + (float)crop[2] / (float)width;
369
- v0 = (float)(crop[1] + crop[3]) / (float)height;
370
- v1 = v0 - (float)crop[3] / (float)height;
349
+ u0 = (float) crop[0] / (float) width;
350
+ u1 = u0 + (float) crop[2] / (float) width;
351
+ v0 = (float) (crop[1] + crop[3]) / (float) height;
352
+ v1 = v0 - (float) crop[3] / (float) height;
371
353
  }
372
354
 
373
-
374
- void updateTex() {
355
+ final void updateTex() {
375
356
  textures[texIndex].setNative(pixels, crop[0] - 1, crop[1] + crop[3] - 1,
376
- crop[2] + 2, -crop[3] + 2);
357
+ crop[2] + 2, -crop[3] + 2);
377
358
  }
378
359
  }
379
360
  }
@@ -393,9 +393,7 @@ public class FrameBuffer implements PConstants {
393
393
  "buffers.");
394
394
  }
395
395
 
396
- for (int i = 0; i < numColorBuffers; i++) {
397
- colorBufferTex[i] = textures[i];
398
- }
396
+ System.arraycopy(textures, 0, colorBufferTex, 0, numColorBuffers);
399
397
 
400
398
  pg.pushFramebuffer();
401
399
  pg.setFramebuffer(this);
@@ -474,7 +472,7 @@ public class FrameBuffer implements PConstants {
474
472
  */
475
473
 
476
474
 
477
- protected void allocate() {
475
+ protected final void allocate() {
478
476
  dispose(); // Just in the case this object is being re-allocated.
479
477
 
480
478
  context = pgl.getCurrentContext();
@@ -598,13 +596,19 @@ public class FrameBuffer implements PConstants {
598
596
  pgl.bindRenderbuffer(PGL.RENDERBUFFER, glDepth);
599
597
 
600
598
  int glConst = PGL.DEPTH_COMPONENT16;
601
- if (depthBits == 16) {
602
- glConst = PGL.DEPTH_COMPONENT16;
603
- } else if (depthBits == 24) {
604
- glConst = PGL.DEPTH_COMPONENT24;
605
- } else if (depthBits == 32) {
606
- glConst = PGL.DEPTH_COMPONENT32;
607
- }
599
+ switch (depthBits) {
600
+ case 16:
601
+ glConst = PGL.DEPTH_COMPONENT16;
602
+ break;
603
+ case 24:
604
+ glConst = PGL.DEPTH_COMPONENT24;
605
+ break;
606
+ case 32:
607
+ glConst = PGL.DEPTH_COMPONENT32;
608
+ break;
609
+ default:
610
+ break;
611
+ }
608
612
 
609
613
  if (multisample) {
610
614
  pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples, glConst,
@@ -635,13 +639,19 @@ public class FrameBuffer implements PConstants {
635
639
  pgl.bindRenderbuffer(PGL.RENDERBUFFER, glStencil);
636
640
 
637
641
  int glConst = PGL.STENCIL_INDEX1;
638
- if (stencilBits == 1) {
639
- glConst = PGL.STENCIL_INDEX1;
640
- } else if (stencilBits == 4) {
641
- glConst = PGL.STENCIL_INDEX4;
642
- } else if (stencilBits == 8) {
643
- glConst = PGL.STENCIL_INDEX8;
644
- }
642
+ switch (stencilBits) {
643
+ case 1:
644
+ glConst = PGL.STENCIL_INDEX1;
645
+ break;
646
+ case 4:
647
+ glConst = PGL.STENCIL_INDEX4;
648
+ break;
649
+ case 8:
650
+ glConst = PGL.STENCIL_INDEX8;
651
+ break;
652
+ default:
653
+ break;
654
+ }
645
655
  if (multisample) {
646
656
  pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples, glConst,
647
657
  width, height);
@@ -357,7 +357,7 @@ public class LinePath {
357
357
 
358
358
  LinePath path;
359
359
 
360
- static final int curvecoords[] = { 2, 2, 0 };
360
+ static final int[] CURVE_COORDS = { 2, 2, 0 };
361
361
 
362
362
  PathIterator(LinePath p2df) {
363
363
  this.path = p2df;
@@ -373,14 +373,14 @@ public class LinePath {
373
373
  */
374
374
  public int currentSegment(float[] coords) {
375
375
  int type = path.pointTypes[typeIdx];
376
- int numCoords = curvecoords[type];
376
+ int numCoords = CURVE_COORDS[type];
377
377
  if (numCoords > 0) {
378
378
  System.arraycopy(floatCoords, pointIdx, coords, 0, numCoords);
379
379
  int color = path.pointColors[colorIdx];
380
380
  coords[numCoords + 0] = (color >> 24) & 0xFF;
381
381
  coords[numCoords + 1] = (color >> 16) & 0xFF;
382
382
  coords[numCoords + 2] = (color >> 8) & 0xFF;
383
- coords[numCoords + 3] = (color >> 0) & 0xFF;
383
+ coords[numCoords + 3] = (color) & 0xFF;
384
384
  }
385
385
  return type;
386
386
  }
@@ -392,7 +392,7 @@ public class LinePath {
392
392
  */
393
393
  public int currentSegment(double[] coords) {
394
394
  int type = path.pointTypes[typeIdx];
395
- int numCoords = curvecoords[type];
395
+ int numCoords = CURVE_COORDS[type];
396
396
  if (numCoords > 0) {
397
397
  for (int i = 0; i < numCoords; i++) {
398
398
  coords[i] = floatCoords[pointIdx + i];
@@ -401,7 +401,7 @@ public class LinePath {
401
401
  coords[numCoords + 0] = (color >> 24) & 0xFF;
402
402
  coords[numCoords + 1] = (color >> 16) & 0xFF;
403
403
  coords[numCoords + 2] = (color >> 8) & 0xFF;
404
- coords[numCoords + 3] = (color >> 0) & 0xFF;
404
+ coords[numCoords + 3] = (color) & 0xFF;
405
405
  }
406
406
  return type;
407
407
  }
@@ -427,8 +427,8 @@ public class LinePath {
427
427
  */
428
428
  public void next() {
429
429
  int type = path.pointTypes[typeIdx++];
430
- if (0 < curvecoords[type]) {
431
- pointIdx += curvecoords[type];
430
+ if (0 < CURVE_COORDS[type]) {
431
+ pointIdx += CURVE_COORDS[type];
432
432
  colorIdx++;
433
433
  }
434
434
  }
@@ -61,9 +61,9 @@ public class LineStroker {
61
61
 
62
62
  private boolean[] penIncluded;
63
63
  private int[] join;
64
- private int[] offset = new int[2];
64
+ private final int[] offset = new int[2];
65
65
  private int[] reverse = new int[100];
66
- private int[] miter = new int[2];
66
+ private final int[] miter = new int[2];
67
67
  private long miterLimitSq;
68
68
  private int prev;
69
69
  private int rindex;
@@ -118,7 +118,7 @@ public class LineStroker {
118
118
  * @param output
119
119
  * an output <code>LineStroker</code>.
120
120
  */
121
- public void setOutput(LineStroker output) {
121
+ private void setOutput(LineStroker output) {
122
122
  this.output = output;
123
123
  }
124
124
 
@@ -141,7 +141,7 @@ public class LineStroker {
141
141
  * required in order to produce consistently shaped end caps and
142
142
  * joins.
143
143
  */
144
- public void setParameters(int lineWidth, int capStyle, int joinStyle,
144
+ public final void setParameters(int lineWidth, int capStyle, int joinStyle,
145
145
  int miterLimit, PMatrix2D transform) {
146
146
  this.m00 = LinePath.FloatToS15_16(transform.m00);
147
147
  this.m01 = LinePath.FloatToS15_16(transform.m01);
@@ -262,18 +262,14 @@ public class LineStroker {
262
262
  if (side == 0) {
263
263
  centerSide = side(cx, cy, xa, ya, xb, yb);
264
264
  } else {
265
- centerSide = (side == 1) ? true : false;
265
+ centerSide = (side == 1);
266
266
  }
267
267
  for (int i = 0; i < numPenSegments; i++) {
268
268
  px = cx + pen_dx[i];
269
269
  py = cy + pen_dy[i];
270
270
 
271
271
  boolean penSide = side(px, py, xa, ya, xb, yb);
272
- if (penSide != centerSide) {
273
- penIncluded[i] = true;
274
- } else {
275
- penIncluded[i] = false;
276
- }
272
+ penIncluded[i] = penSide != centerSide;
277
273
  }
278
274
 
279
275
  int start = -1, end = -1;
@@ -131,12 +131,12 @@ public abstract class PGL {
131
131
  * shorts as primitive type we have 2^15 = 32768 as the maximum number of
132
132
  * vertices that can be referred to within a single VBO.
133
133
  */
134
- protected static int MAX_VERTEX_INDEX = 32767;
134
+ protected static final int MAX_VERTEX_INDEX = 32767;
135
135
 
136
136
  /**
137
137
  *
138
138
  */
139
- protected static int MAX_VERTEX_INDEX1 = MAX_VERTEX_INDEX + 1;
139
+ protected static final int MAX_VERTEX_INDEX1 = MAX_VERTEX_INDEX + 1;
140
140
 
141
141
  /** Count of tessellated fill, line or point vertices that will
142
142
  * trigger a flush in the immediate mode. It doesn't necessarily
@@ -643,7 +643,7 @@ public abstract class PGL {
643
643
  // Constants
644
644
 
645
645
  /** Size of different types in bytes */
646
- protected static int SIZEOF_SHORT = Short.SIZE / 8;
646
+ protected static final int SIZEOF_SHORT = Short.SIZE / 8;
647
647
 
648
648
  /**
649
649
  *
@@ -827,15 +827,16 @@ public abstract class PGL {
827
827
  * @return
828
828
  */
829
829
  static public int smoothToSamples(int smooth) {
830
- if (smooth == 0) {
831
- // smooth(0) is noSmooth(), which is 1x sampling
832
- return 1;
833
- } else if (smooth == 1) {
834
- // smooth(1) means "default smoothing", which is 2x for OpenGL
835
- return 2;
836
- } else {
837
- // smooth(N) can be used for 4x, 8x, etc
838
- return smooth;
830
+ switch (smooth) {
831
+ case 0:
832
+ // smooth(0) is noSmooth(), which is 1x sampling
833
+ return 1;
834
+ case 1:
835
+ // smooth(1) means "default smoothing", which is 2x for OpenGL
836
+ return 2;
837
+ default:
838
+ // smooth(N) can be used for 4x, 8x, etc
839
+ return smooth;
839
840
  }
840
841
  }
841
842
 
@@ -905,7 +906,7 @@ public abstract class PGL {
905
906
  *
906
907
  * @return
907
908
  */
908
- protected boolean isFBOBacked() {;
909
+ protected boolean isFBOBacked() {
909
910
  return fboLayerEnabled;
910
911
  }
911
912
 
@@ -966,7 +967,7 @@ public abstract class PGL {
966
967
  protected boolean getDepthTest() {
967
968
  intBuffer.rewind();
968
969
  getBooleanv(DEPTH_TEST, intBuffer);
969
- return intBuffer.get(0) == 0 ? false : true;
970
+ return intBuffer.get(0) != 0;
970
971
  }
971
972
 
972
973
  /**
@@ -976,7 +977,7 @@ public abstract class PGL {
976
977
  protected boolean getDepthWriteMask() {
977
978
  intBuffer.rewind();
978
979
  getBooleanv(DEPTH_WRITEMASK, intBuffer);
979
- return intBuffer.get(0) == 0 ? false : true;
980
+ return intBuffer.get(0) != 0;
980
981
  }
981
982
 
982
983
  /**
@@ -1306,13 +1307,13 @@ public abstract class PGL {
1306
1307
  float ba = ((stopButtonColor >> 24) & 0xFF) / 255f;
1307
1308
  float br = ((stopButtonColor >> 16) & 0xFF) / 255f;
1308
1309
  float bg = ((stopButtonColor >> 8) & 0xFF) / 255f;
1309
- float bb = ((stopButtonColor >> 0) & 0xFF) / 255f;
1310
+ float bb = ((stopButtonColor) & 0xFF) / 255f;
1310
1311
  for (int i = 0; i < color.length; i++) {
1311
1312
  int c = closeButtonPix[i];
1312
1313
  int a = (int)(ba * ((c >> 24) & 0xFF));
1313
1314
  int r = (int)(br * ((c >> 16) & 0xFF));
1314
1315
  int g = (int)(bg * ((c >> 8) & 0xFF));
1315
- int b = (int)(bb * ((c >> 0) & 0xFF));
1316
+ int b = (int)(bb * ((c) & 0xFF));
1316
1317
  color[i] = javaToNativeARGB((a << 24) | (r << 16) | (g << 8) | b);
1317
1318
  }
1318
1319
  IntBuffer buf = allocateIntBuffer(color);
@@ -1614,12 +1615,18 @@ public abstract class PGL {
1614
1615
  // separate depth and stencil buffers
1615
1616
  if (0 < depthBits) {
1616
1617
  int depthComponent = DEPTH_COMPONENT16;
1617
- if (depthBits == 32) {
1618
- depthComponent = DEPTH_COMPONENT32;
1619
- } else if (depthBits == 24) {
1620
- depthComponent = DEPTH_COMPONENT24;
1621
- } else if (depthBits == 16) {
1622
- depthComponent = DEPTH_COMPONENT16;
1618
+ switch (depthBits) {
1619
+ case 32:
1620
+ depthComponent = DEPTH_COMPONENT32;
1621
+ break;
1622
+ case 24:
1623
+ depthComponent = DEPTH_COMPONENT24;
1624
+ break;
1625
+ case 16:
1626
+ depthComponent = DEPTH_COMPONENT16;
1627
+ break;
1628
+ default:
1629
+ break;
1623
1630
  }
1624
1631
 
1625
1632
  IntBuffer depthBuf = multisample ? glMultiDepth : glDepth;
@@ -1638,12 +1645,18 @@ public abstract class PGL {
1638
1645
 
1639
1646
  if (0 < stencilBits) {
1640
1647
  int stencilIndex = STENCIL_INDEX1;
1641
- if (stencilBits == 8) {
1642
- stencilIndex = STENCIL_INDEX8;
1643
- } else if (stencilBits == 4) {
1644
- stencilIndex = STENCIL_INDEX4;
1645
- } else if (stencilBits == 1) {
1646
- stencilIndex = STENCIL_INDEX1;
1648
+ switch (stencilBits) {
1649
+ case 8:
1650
+ stencilIndex = STENCIL_INDEX8;
1651
+ break;
1652
+ case 4:
1653
+ stencilIndex = STENCIL_INDEX4;
1654
+ break;
1655
+ case 1:
1656
+ stencilIndex = STENCIL_INDEX1;
1657
+ break;
1658
+ default:
1659
+ break;
1647
1660
  }
1648
1661
 
1649
1662
  IntBuffer stencilBuf = multisample ? glMultiStencil : glStencil;
@@ -2824,8 +2837,7 @@ public abstract class PGL {
2824
2837
  * @return
2825
2838
  */
2826
2839
  protected static boolean containsVersionDirective(String[] shSrc) {
2827
- for (int i = 0; i < shSrc.length; i++) {
2828
- String line = shSrc[i];
2840
+ for (String line : shSrc) {
2829
2841
  int versionIndex = line.indexOf("#version");
2830
2842
  if (versionIndex >= 0) {
2831
2843
  int commentIndex = line.indexOf("//");
@@ -2888,7 +2900,7 @@ public abstract class PGL {
2888
2900
  protected boolean compiled(int shader) {
2889
2901
  intBuffer.rewind();
2890
2902
  getShaderiv(shader, COMPILE_STATUS, intBuffer);
2891
- return intBuffer.get(0) == 0 ? false : true;
2903
+ return intBuffer.get(0) != 0;
2892
2904
  }
2893
2905
 
2894
2906
  /**
@@ -2899,7 +2911,7 @@ public abstract class PGL {
2899
2911
  protected boolean linked(int program) {
2900
2912
  intBuffer.rewind();
2901
2913
  getProgramiv(program, LINK_STATUS, intBuffer);
2902
- return intBuffer.get(0) == 0 ? false : true;
2914
+ return intBuffer.get(0) != 0;
2903
2915
  }
2904
2916
 
2905
2917
  /**
@@ -2970,9 +2982,9 @@ public abstract class PGL {
2970
2982
 
2971
2983
  int[] res = {0, 0, 0};
2972
2984
  String[] parts = version.split(" ");
2973
- for (int i = 0; i < parts.length; i++) {
2974
- if (0 < parts[i].indexOf(".")) {
2975
- String nums[] = parts[i].split("\\.");
2985
+ for (String part : parts) {
2986
+ if (0 < part.indexOf(".")) {
2987
+ String[] nums = part.split("\\.");
2976
2988
  try {
2977
2989
  res[0] = Integer.parseInt(nums[0]);
2978
2990
  } catch (NumberFormatException e) { }
@@ -3001,10 +3013,10 @@ public abstract class PGL {
3001
3013
  int major = getGLVersion()[0];
3002
3014
  if (major < 2) {
3003
3015
  String ext = getString(EXTENSIONS);
3004
- return ext.indexOf("_framebuffer_object") != -1 &&
3005
- ext.indexOf("_vertex_shader") != -1 &&
3006
- ext.indexOf("_shader_objects") != -1 &&
3007
- ext.indexOf("_shading_language") != -1;
3016
+ return ext.contains("_framebuffer_object") &&
3017
+ ext.contains("_vertex_shader") &&
3018
+ ext.contains("_shader_objects") &&
3019
+ ext.contains("_shading_language");
3008
3020
  } else {
3009
3021
  return true;
3010
3022
  }
@@ -3021,10 +3033,10 @@ public abstract class PGL {
3021
3033
  int major = getGLVersion()[0];
3022
3034
  if (major < 2) {
3023
3035
  String ext = getString(EXTENSIONS);
3024
- return ext.indexOf("_fragment_shader") != -1 &&
3025
- ext.indexOf("_vertex_shader") != -1 &&
3026
- ext.indexOf("_shader_objects") != -1 &&
3027
- ext.indexOf("_shading_language") != -1;
3036
+ return ext.contains("_fragment_shader") &&
3037
+ ext.contains("_vertex_shader") &&
3038
+ ext.contains("_shader_objects") &&
3039
+ ext.contains("_shading_language");
3028
3040
  } else {
3029
3041
  return true;
3030
3042
  }