propane 3.5.0-java → 3.6.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/extensions.xml +1 -1
  3. data/.mvn/wrapper/MavenWrapperDownloader.java +1 -1
  4. data/.mvn/wrapper/maven-wrapper.properties +2 -2
  5. data/.travis.yml +1 -1
  6. data/CHANGELOG.md +3 -1
  7. data/README.md +5 -13
  8. data/Rakefile +1 -1
  9. data/lib/propane.rb +2 -1
  10. data/lib/propane/helper_methods.rb +0 -1
  11. data/lib/propane/runner.rb +2 -0
  12. data/lib/propane/version.rb +1 -1
  13. data/pom.rb +43 -43
  14. data/pom.xml +4 -4
  15. data/propane.gemspec +4 -3
  16. data/src/main/java/japplemenubar/JAppleMenuBar.java +3 -3
  17. data/src/main/java/processing/awt/PGraphicsJava2D.java +8 -17
  18. data/src/main/java/processing/awt/PImageAWT.java +123 -6
  19. data/src/main/java/processing/awt/PShapeJava2D.java +1 -0
  20. data/src/main/java/processing/awt/PSurfaceAWT.java +9 -7
  21. data/src/main/java/processing/awt/ShimAWT.java +2 -1
  22. data/src/main/java/processing/core/PApplet.java +4605 -6014
  23. data/src/main/java/processing/core/PConstants.java +5 -5
  24. data/src/main/java/processing/core/PFont.java +5 -17
  25. data/src/main/java/processing/core/PGraphics.java +308 -320
  26. data/src/main/java/processing/core/PImage.java +1440 -1537
  27. data/src/main/java/processing/core/PMatrix2D.java +24 -7
  28. data/src/main/java/processing/core/PMatrix3D.java +12 -5
  29. data/src/main/java/processing/core/PShape.java +155 -173
  30. data/src/main/java/processing/core/PShapeOBJ.java +2 -0
  31. data/src/main/java/processing/core/PShapeSVG.java +632 -611
  32. data/src/main/java/processing/core/PSurface.java +15 -10
  33. data/src/main/java/processing/core/PSurfaceNone.java +8 -4
  34. data/src/main/java/processing/core/PVector.java +35 -28
  35. data/src/main/java/processing/data/Table.java +20 -20
  36. data/src/main/java/processing/data/XML.java +1 -1
  37. data/src/main/java/processing/event/Event.java +1 -1
  38. data/src/main/java/processing/event/MouseEvent.java +7 -6
  39. data/src/main/java/processing/javafx/PGraphicsFX2D.java +20 -345
  40. data/src/main/java/processing/javafx/PSurfaceFX.java +127 -125
  41. data/src/main/java/processing/opengl/FrameBuffer.java +2 -4
  42. data/src/main/java/processing/opengl/LinePath.java +4 -0
  43. data/src/main/java/processing/opengl/LineStroker.java +2 -6
  44. data/src/main/java/processing/opengl/PGL.java +72 -45
  45. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +106 -60
  46. data/src/main/java/processing/opengl/PJOGL.java +15 -3
  47. data/src/main/java/processing/opengl/PShader.java +26 -47
  48. data/src/main/java/processing/opengl/PShapeOpenGL.java +1041 -1001
  49. data/src/main/java/processing/opengl/PSurfaceJOGL.java +211 -208
  50. data/src/main/java/processing/opengl/Texture.java +7 -4
  51. data/src/main/java/processing/opengl/VertexBuffer.java +2 -2
  52. data/vendors/Rakefile +22 -33
  53. metadata +38 -18
@@ -258,9 +258,7 @@ public class FrameBuffer implements PConstants {
258
258
  "buffers.");
259
259
  }
260
260
 
261
- for (int i = 0; i < numColorBuffers; i++) {
262
- colorBufferTex[i] = textures[i];
263
- }
261
+ System.arraycopy(textures, 0, colorBufferTex, 0, numColorBuffers);
264
262
 
265
263
  pg.pushFramebuffer();
266
264
  pg.setFramebuffer(this);
@@ -327,7 +325,7 @@ public class FrameBuffer implements PConstants {
327
325
  // Allocate/release framebuffer.
328
326
 
329
327
 
330
- protected void allocate() {
328
+ protected final void allocate() {
331
329
  dispose(); // Just in the case this object is being re-allocated.
332
330
 
333
331
  context = pgl.getCurrentContext();
@@ -219,6 +219,7 @@ public class LinePath {
219
219
  * the specified X coordinate
220
220
  * @param y
221
221
  * the specified Y coordinate
222
+ * @param c
222
223
  * @see LinePath#moveTo
223
224
  */
224
225
  public final void moveTo(float x, float y, int c) {
@@ -247,6 +248,7 @@ public class LinePath {
247
248
  * the specified X coordinate
248
249
  * @param y
249
250
  * the specified Y coordinate
251
+ * @param c
250
252
  * @see LinePath#lineTo
251
253
  */
252
254
  public final void lineTo(float x, float y, int c) {
@@ -263,6 +265,7 @@ public class LinePath {
263
265
  * the {@code LinePath} class does not guarantee that modifications to the
264
266
  * geometry of this {@code LinePath} object do not affect any iterations of that
265
267
  * geometry that are already in process.
268
+ * @return
266
269
  */
267
270
  public PathIterator getPathIterator() {
268
271
  return new PathIterator(this);
@@ -421,6 +424,7 @@ public class LinePath {
421
424
  * the decoration applied where path segments meet
422
425
  * @param miterlimit
423
426
  * @param transform
427
+ * @return
424
428
  *
425
429
  */
426
430
  static public LinePath createStrokedPath(LinePath src, float weight,
@@ -258,18 +258,14 @@ public class LineStroker {
258
258
  if (side == 0) {
259
259
  centerSide = side(cx, cy, xa, ya, xb, yb);
260
260
  } else {
261
- centerSide = (side == 1) ? true : false;
261
+ centerSide = (side == 1);
262
262
  }
263
263
  for (int i = 0; i < numPenSegments; i++) {
264
264
  px = cx + pen_dx[i];
265
265
  py = cy + pen_dy[i];
266
266
 
267
267
  boolean penSide = side(px, py, xa, ya, xb, yb);
268
- if (penSide != centerSide) {
269
- penIncluded[i] = true;
270
- } else {
271
- penIncluded[i] = false;
272
- }
268
+ penIncluded[i] = penSide != centerSide;
273
269
  }
274
270
 
275
271
  int start = -1, end = -1;
@@ -33,12 +33,12 @@ import java.nio.FloatBuffer;
33
33
  import java.nio.IntBuffer;
34
34
  import java.nio.ShortBuffer;
35
35
  import java.util.Arrays;
36
- import java.util.Optional;
37
36
  import java.util.regex.Pattern;
38
37
 
39
38
  import processing.core.PApplet;
40
39
  import processing.core.PConstants;
41
40
  import processing.core.PGraphics;
41
+ import processing.core.PImage;
42
42
 
43
43
 
44
44
  /**
@@ -56,6 +56,7 @@ public abstract class PGL {
56
56
  /** The PGraphics and PApplet objects using this interface */
57
57
  protected PGraphicsOpenGL graphics;
58
58
  protected PApplet sketch;
59
+ protected RenderCallback renderCallback;
59
60
 
60
61
  /** OpenGL thread */
61
62
  protected Thread glThread;
@@ -96,8 +97,8 @@ public abstract class PGL {
96
97
  * shorts as primitive type we have 2^15 = 32768 as the maximum number of
97
98
  * vertices that can be referred to within a single VBO.
98
99
  */
99
- protected static int MAX_VERTEX_INDEX = 32767;
100
- protected static int MAX_VERTEX_INDEX1 = MAX_VERTEX_INDEX + 1;
100
+ protected static final int MAX_VERTEX_INDEX = 32767;
101
+ protected static final int MAX_VERTEX_INDEX1 = MAX_VERTEX_INDEX + 1;
101
102
 
102
103
  /** Count of tessellated fill, line or point vertices that will
103
104
  * trigger a flush in the immediate mode. It doesn't necessarily
@@ -170,9 +171,12 @@ public abstract class PGL {
170
171
  * Defines if FBO Layer is allowed in the given environment.
171
172
  * Using FBO can cause a fatal error during runtime for
172
173
  * Intel HD Graphics 3000 chipsets (commonly used on older MacBooks)
173
- * <a href="https://github.com/processing/processing/issues/4104">#4104</a>
174
+ * <a href="https://github.com/processing/processing/issues/4104">#4104</a>.
175
+ * Changed to private because needs to be accessed via isFboAllowed().
176
+ * <a href="https://github.com/processing/processing4/pull/76">#76</a> and
177
+ * <a href="https://github.com/processing/processing4/issues/50">#50</a>
174
178
  */
175
- private Optional<Boolean> fboAllowed = Optional.empty();
179
+ private Boolean fboAllowed = true;
176
180
 
177
181
  // ........................................................
178
182
 
@@ -330,7 +334,7 @@ public abstract class PGL {
330
334
  // Constants
331
335
 
332
336
  /** Size of different types in bytes */
333
- protected static int SIZEOF_SHORT = Short.SIZE / 8;
337
+ protected static final int SIZEOF_SHORT = Short.SIZE / 8;
334
338
  protected static int SIZEOF_INT = Integer.SIZE / 8;
335
339
  protected static int SIZEOF_FLOAT = Float.SIZE / 8;
336
340
  protected static int SIZEOF_BYTE = Byte.SIZE / 8;
@@ -398,11 +402,26 @@ public abstract class PGL {
398
402
  // Initialization, finalization
399
403
 
400
404
 
401
- public PGL() { }
405
+ public PGL() {
406
+ this.renderCallback = () -> {};
407
+ }
402
408
 
403
409
 
404
410
  public PGL(PGraphicsOpenGL pg) {
405
411
  this.graphics = pg;
412
+ this.renderCallback = () -> {};
413
+ initGraphics();
414
+ }
415
+
416
+
417
+ public PGL(PGraphicsOpenGL pg, RenderCallback newCallback) {
418
+ this.graphics = pg;
419
+ this.renderCallback = newCallback;
420
+ initGraphics();
421
+ }
422
+
423
+
424
+ private void initGraphics() {
406
425
  if (glColorTex == null) {
407
426
  glColorFbo = allocateIntBuffer(1);
408
427
  glColorTex = allocateIntBuffer(2);
@@ -463,6 +482,9 @@ public abstract class PGL {
463
482
  abstract protected void registerListeners();
464
483
 
465
484
 
485
+ abstract protected PImage screenshot();
486
+
487
+
466
488
  protected int getReadFramebuffer() {
467
489
  return fboLayerEnabled ? glColorFbo.get(0) : 0;
468
490
  }
@@ -525,14 +547,14 @@ public abstract class PGL {
525
547
  protected boolean getDepthTest() {
526
548
  intBuffer.rewind();
527
549
  getBooleanv(DEPTH_TEST, intBuffer);
528
- return intBuffer.get(0) != 0;
550
+ return intBuffer.get(0) == 0 ? false : true;
529
551
  }
530
552
 
531
553
 
532
554
  protected boolean getDepthWriteMask() {
533
555
  intBuffer.rewind();
534
556
  getBooleanv(DEPTH_WRITEMASK, intBuffer);
535
- return intBuffer.get(0) != 0;
557
+ return intBuffer.get(0) == 0 ? false : true;
536
558
  }
537
559
 
538
560
 
@@ -809,13 +831,13 @@ public abstract class PGL {
809
831
  float ba = ((stopButtonColor >> 24) & 0xFF) / 255f;
810
832
  float br = ((stopButtonColor >> 16) & 0xFF) / 255f;
811
833
  float bg = ((stopButtonColor >> 8) & 0xFF) / 255f;
812
- float bb = ((stopButtonColor >> 0) & 0xFF) / 255f;
834
+ float bb = ((stopButtonColor) & 0xFF) / 255f;
813
835
  for (int i = 0; i < color.length; i++) {
814
836
  int c = closeButtonPix[i];
815
837
  int a = (int)(ba * ((c >> 24) & 0xFF));
816
838
  int r = (int)(br * ((c >> 16) & 0xFF));
817
839
  int g = (int)(bg * ((c >> 8) & 0xFF));
818
- int b = (int)(bb * ((c >> 0) & 0xFF));
840
+ int b = (int)(bb * ((c) & 0xFF));
819
841
  color[i] = javaToNativeARGB((a << 24) | (r << 16) | (g << 8) | b);
820
842
  }
821
843
  IntBuffer buf = allocateIntBuffer(color);
@@ -862,7 +884,7 @@ public abstract class PGL {
862
884
  saveFirstFrame();
863
885
  }
864
886
 
865
- if (getIsFboAllowed()) {
887
+ if (isFboAllowed()) {
866
888
  if (!clearColor && 0 < sketch.frameCount || !sketch.isLooping()) {
867
889
  enableFBOLayer();
868
890
  if (SINGLE_BUFFERED) {
@@ -871,6 +893,8 @@ public abstract class PGL {
871
893
  }
872
894
  }
873
895
  }
896
+
897
+ renderCallback.onRender();
874
898
  }
875
899
 
876
900
 
@@ -1117,12 +1141,18 @@ public abstract class PGL {
1117
1141
 
1118
1142
  if (0 < stencilBits) {
1119
1143
  int stencilIndex = STENCIL_INDEX1;
1120
- if (stencilBits == 8) {
1121
- stencilIndex = STENCIL_INDEX8;
1122
- } else if (stencilBits == 4) {
1123
- stencilIndex = STENCIL_INDEX4;
1124
- } else if (stencilBits == 1) {
1125
- stencilIndex = STENCIL_INDEX1;
1144
+ switch (stencilBits) {
1145
+ case 8:
1146
+ stencilIndex = STENCIL_INDEX8;
1147
+ break;
1148
+ case 4:
1149
+ stencilIndex = STENCIL_INDEX4;
1150
+ break;
1151
+ case 1:
1152
+ stencilIndex = STENCIL_INDEX1;
1153
+ break;
1154
+ default:
1155
+ break;
1126
1156
  }
1127
1157
 
1128
1158
  IntBuffer stencilBuf = multisample ? glMultiStencil : glStencil;
@@ -1615,6 +1645,8 @@ public abstract class PGL {
1615
1645
  /**
1616
1646
  * Converts input native OpenGL value (RGBA on big endian, ABGR on little
1617
1647
  * endian) to Java ARGB.
1648
+ * @param color
1649
+ * @return
1618
1650
  */
1619
1651
  protected static int nativeToJavaARGB(int color) {
1620
1652
  if (BIG_ENDIAN) { // RGBA to ARGB
@@ -1791,10 +1823,11 @@ public abstract class PGL {
1791
1823
  }
1792
1824
  }
1793
1825
 
1794
-
1795
1826
  /**
1796
1827
  * Converts input Java ARGB value to native OpenGL format (RGBA on big endian,
1797
1828
  * BGRA on little endian), setting alpha component to opaque (255).
1829
+ * @param color
1830
+ * @return
1798
1831
  */
1799
1832
  protected static int javaToNativeRGB(int color) {
1800
1833
  if (BIG_ENDIAN) { // ARGB to RGB
@@ -2307,39 +2340,26 @@ public abstract class PGL {
2307
2340
  return intBuffer.get(0);
2308
2341
  }
2309
2342
 
2310
-
2311
- /**
2312
- * Determine if the renderer / hardware supports frame buffer objects (FBOs).
2313
- *
2314
- * @return True if confirmed that FBOs are supported by the renderer on the current hardware. Will
2315
- * be false if the support status has not been confirmed yet (for example, because the graphics
2316
- * context has not been itiliazed) or if it is confirmed that the renderer / hardware
2317
- * combination do not support FBOs.
2318
- */
2319
- protected boolean getIsFboAllowed() {
2320
-
2321
- // If not yet determined, try to find.
2322
- if (fboAllowed.isEmpty()) {
2323
- boolean isNoFboRenderer;
2343
+
2344
+ public boolean isFboAllowed() {
2345
+ if (fboAllowed == null) {
2324
2346
  if (PApplet.platform == PConstants.MACOS) {
2325
- String rendererName;
2326
2347
  try {
2327
- rendererName = getString(PGL.RENDERER);
2328
- isNoFboRenderer = String.valueOf(rendererName).contains("Intel HD Graphics 3000");
2348
+ String hardware = getString(PGL.RENDERER);
2349
+ if (hardware != null && hardware.contains("Intel HD Graphics 3000")) {
2350
+ fboAllowed = false;
2351
+ return false;
2352
+ }
2329
2353
  } catch (RuntimeException e) {
2330
2354
  System.err.println("Could not read renderer name. FBOs disabled. Reason: " + e);
2331
- return false; // Try again later.
2355
+ // disable for now, but will try again on next isFboAllowed() call
2356
+ return false;
2332
2357
  }
2333
- } else {
2334
- isNoFboRenderer = false;
2335
2358
  }
2336
-
2337
- // Cache value.
2338
- fboAllowed = Optional.of(!isNoFboRenderer);
2359
+ // all other scenarios allow for FBOs
2360
+ fboAllowed = true;
2339
2361
  }
2340
-
2341
- // Return cached value.
2342
- return fboAllowed.get();
2362
+ return fboAllowed;
2343
2363
  }
2344
2364
 
2345
2365
 
@@ -2723,6 +2743,13 @@ public abstract class PGL {
2723
2743
 
2724
2744
  abstract protected Object getDerivedFont(Object font, float size);
2725
2745
 
2746
+ ///////////////////////////////////////////////////////////
2747
+
2748
+ protected interface RenderCallback {
2749
+
2750
+ void onRender();
2751
+
2752
+ }
2726
2753
 
2727
2754
  ///////////////////////////////////////////////////////////
2728
2755
 
@@ -47,13 +47,17 @@ public class PGraphicsOpenGL extends PGraphics {
47
47
  /** Font cache for texture objects. */
48
48
  protected WeakHashMap<PFont, FontTexture> fontMap;
49
49
 
50
+ // Blocking save
51
+ protected volatile Object saveBlocker;
52
+ private volatile Optional<String> saveTargetMaybe;
53
+
50
54
  // ........................................................
51
55
 
52
56
  // Disposal of native resources
53
57
  // Using the technique alternative to finalization described in:
54
58
  // http://www.oracle.com/technetwork/articles/java/finalization-137655.html
55
- private static ReferenceQueue<Object> refQueue = new ReferenceQueue<>();
56
- private static List<Disposable<?>> reachableWeakReferences =
59
+ private static final ReferenceQueue<Object> refQueue = new ReferenceQueue<>();
60
+ private static final List<Disposable<?>> reachableWeakReferences =
57
61
  new LinkedList<>();
58
62
 
59
63
  static final private int MAX_DRAIN_GLRES_ITERATIONS = 10;
@@ -568,6 +572,9 @@ public class PGraphicsOpenGL extends PGraphics {
568
572
  public PGraphicsOpenGL() {
569
573
  pgl = createPGL(this);
570
574
 
575
+ saveTargetMaybe = Optional.empty();
576
+ saveBlocker = new Object();
577
+
571
578
  if (intBuffer == null) {
572
579
  intBuffer = PGL.allocateIntBuffer(2);
573
580
  floatBuffer = PGL.allocateFloatBuffer(2);
@@ -709,7 +716,7 @@ public class PGraphicsOpenGL extends PGraphics {
709
716
 
710
717
  // Factory method
711
718
  protected PGL createPGL(PGraphicsOpenGL pg) {
712
- return new PJOGL(pg);
719
+ return new PJOGL(pg, () -> { onRender(); });
713
720
  // return new PGLES(pg);
714
721
  }
715
722
 
@@ -756,18 +763,30 @@ public class PGraphicsOpenGL extends PGraphics {
756
763
  // return super.save(filename); // ASYNC save frame using PBOs not yet available on Android
757
764
 
758
765
  if (getHint(DISABLE_ASYNC_SAVEFRAME)) {
759
- // Act as an opaque surface for the purposes of saving.
760
- if (primaryGraphics) {
761
- int prevFormat = format;
762
- format = RGB;
763
- boolean result = super.save(filename);
764
- format = prevFormat;
765
- return result;
766
+ saveTargetMaybe = Optional.of(filename);
767
+
768
+ if (!drawing) {
769
+ beginDraw();
766
770
  }
771
+ flush();
772
+ updatePixelSize();
773
+ endDraw(); // Briefly stop drawing
767
774
 
768
- return super.save(filename);
775
+ synchronized(saveBlocker) {
776
+ try {
777
+ while (saveTargetMaybe.isPresent()) {
778
+ saveBlocker.wait();
779
+ }
780
+ beginDraw(); // Resume drawing
781
+ return true;
782
+ } catch (InterruptedException e) {
783
+ return false;
784
+ }
785
+ }
769
786
  }
770
787
 
788
+ boolean needEndDraw = false;
789
+
771
790
  if (asyncImageSaver == null) {
772
791
  asyncImageSaver = new AsyncImageSaver();
773
792
  }
@@ -781,7 +800,6 @@ public class PGraphicsOpenGL extends PGraphics {
781
800
  }
782
801
 
783
802
  if (asyncPixelReader != null && !loaded) {
784
- boolean needEndDraw = false;
785
803
  if (!drawing) {
786
804
  beginDraw();
787
805
  needEndDraw = true;
@@ -810,6 +828,21 @@ public class PGraphicsOpenGL extends PGraphics {
810
828
  }
811
829
 
812
830
 
831
+ private void onRender() {
832
+ if (saveTargetMaybe.isEmpty()) {
833
+ return; // Nothing to save
834
+ }
835
+
836
+ PImage outputImage = pgl.screenshot();
837
+ outputImage.save(saveTargetMaybe.get());
838
+ saveTargetMaybe = Optional.empty();
839
+
840
+ synchronized(saveBlocker) {
841
+ saveBlocker.notify();
842
+ }
843
+ }
844
+
845
+
813
846
  //////////////////////////////////////////////////////////////
814
847
 
815
848
  // IMAGE METADATA FOR THIS RENDERER
@@ -920,7 +953,7 @@ public class PGraphicsOpenGL extends PGraphics {
920
953
  int glId;
921
954
 
922
955
  private PGL pgl;
923
- private int context;
956
+ private final int context;
924
957
 
925
958
  public GLResourceVertexBuffer(VertexBuffer vbo) {
926
959
  super(vbo);
@@ -971,7 +1004,7 @@ public class PGraphicsOpenGL extends PGraphics {
971
1004
  int glFragment;
972
1005
 
973
1006
  private PGL pgl;
974
- private int context;
1007
+ private final int context;
975
1008
 
976
1009
  public GLResourceShader(PShader sh) {
977
1010
  super(sh);
@@ -1039,7 +1072,7 @@ public class PGraphicsOpenGL extends PGraphics {
1039
1072
  int glMultisample;
1040
1073
 
1041
1074
  private PGL pgl;
1042
- private int context;
1075
+ private final int context;
1043
1076
 
1044
1077
  public GLResourceFrameBuffer(FrameBuffer fb) {
1045
1078
  super(fb);
@@ -4558,11 +4591,11 @@ public class PGraphicsOpenGL extends PGraphics {
4558
4591
  * Calls perspective() with Processing's standard coordinate projection.
4559
4592
  * <P>
4560
4593
  * Projection functions:
4561
- * <ul>
4562
- * <li>frustrum()
4563
- * <li>ortho()
4564
- * <li>perspective()
4565
- * </ul>
4594
+ * <UL>
4595
+ * <LI>frustrum()
4596
+ * <LI>ortho()
4597
+ * <LI>perspective()
4598
+ * </UL>
4566
4599
  * Each of these three functions completely replaces the projection matrix
4567
4600
  * with a new one. They can be called inside setup(), and their effects will
4568
4601
  * be felt inside draw(). At the top of draw(), the projection matrix is not
@@ -4598,6 +4631,8 @@ public class PGraphicsOpenGL extends PGraphics {
4598
4631
  * against) the current perspective matrix.
4599
4632
  * <P>
4600
4633
  * Implementation based on the explanation in the OpenGL blue book.
4634
+ * @param znear
4635
+ * @param zfar
4601
4636
  */
4602
4637
  @Override
4603
4638
  public void frustum(float left, float right, float bottom, float top,
@@ -6938,15 +6973,16 @@ public class PGraphicsOpenGL extends PGraphics {
6938
6973
  maxTextureSize = intBuffer.get(0);
6939
6974
 
6940
6975
  // work around runtime exceptions in Broadcom's VC IV driver
6941
- if (false == OPENGL_RENDERER.equals("VideoCore IV HW")) {
6942
- pgl.getIntegerv(PGL.MAX_SAMPLES, intBuffer);
6943
- maxSamples = intBuffer.get(0);
6944
- }
6976
+ // if (false == OPENGL_RENDERER.equals("VideoCore IV HW")) {
6977
+ pgl.getIntegerv(PGL.MAX_SAMPLES, intBuffer);
6978
+ maxSamples = intBuffer.get(0);
6979
+ // }
6945
6980
 
6946
6981
  if (anisoSamplingSupported) {
6947
6982
  pgl.getFloatv(PGL.MAX_TEXTURE_MAX_ANISOTROPY, floatBuffer);
6948
6983
  maxAnisoAmount = floatBuffer.get(0);
6949
6984
  }
6985
+
6950
6986
  glParamsRead = true;
6951
6987
  }
6952
6988
 
@@ -7073,15 +7109,21 @@ public class PGraphicsOpenGL extends PGraphics {
7073
7109
  @Override
7074
7110
  public void resetShader(int kind) {
7075
7111
  flush(); // Flushing geometry drawn with a different shader.
7076
-
7077
- if (kind == TRIANGLES || kind == QUADS || kind == POLYGON) {
7078
- polyShader = null;
7079
- } else if (kind == LINES) {
7080
- lineShader = null;
7081
- } else if (kind == POINTS) {
7082
- pointShader = null;
7083
- } else {
7084
- PGraphics.showWarning(UNKNOWN_SHADER_KIND_ERROR);
7112
+ switch (kind) {
7113
+ case TRIANGLES:
7114
+ case QUADS:
7115
+ case POLYGON:
7116
+ polyShader = null;
7117
+ break;
7118
+ case LINES:
7119
+ lineShader = null;
7120
+ break;
7121
+ case POINTS:
7122
+ pointShader = null;
7123
+ break;
7124
+ default:
7125
+ PGraphics.showWarning(UNKNOWN_SHADER_KIND_ERROR);
7126
+ break;
7085
7127
  }
7086
7128
  }
7087
7129
 
@@ -7450,7 +7492,7 @@ public class PGraphicsOpenGL extends PGraphics {
7450
7492
  allocate();
7451
7493
  }
7452
7494
 
7453
- void allocate() {
7495
+ final void allocate() {
7454
7496
  textures = new PImage[PGL.DEFAULT_IN_TEXTURES];
7455
7497
  firstIndex = new int[PGL.DEFAULT_IN_TEXTURES];
7456
7498
  lastIndex = new int[PGL.DEFAULT_IN_TEXTURES];
@@ -7567,7 +7609,7 @@ public class PGraphicsOpenGL extends PGraphics {
7567
7609
  allocate();
7568
7610
  }
7569
7611
 
7570
- void allocate() {
7612
+ final void allocate() {
7571
7613
  size = 0;
7572
7614
  indexCount = new int[2];
7573
7615
  indexOffset = new int[2];
@@ -7734,7 +7776,7 @@ public class PGraphicsOpenGL extends PGraphics {
7734
7776
  edgeCount = 0;
7735
7777
  }
7736
7778
 
7737
- void allocate() {
7779
+ final void allocate() {
7738
7780
  vertices = new float[3 * PGL.DEFAULT_IN_VERTICES];
7739
7781
  colors = new int[PGL.DEFAULT_IN_VERTICES];
7740
7782
  normals = new float[3 * PGL.DEFAULT_IN_VERTICES];
@@ -8384,7 +8426,7 @@ public class PGraphicsOpenGL extends PGraphics {
8384
8426
 
8385
8427
  vert[R] = ((colors[i] >> 16) & 0xFF) / 255.0f;
8386
8428
  vert[G] = ((colors[i] >> 8) & 0xFF) / 255.0f;
8387
- vert[B] = ((colors[i] >> 0) & 0xFF) / 255.0f;
8429
+ vert[B] = ((colors[i]) & 0xFF) / 255.0f;
8388
8430
  vert[A] = ((colors[i] >> 24) & 0xFF) / 255.0f;
8389
8431
 
8390
8432
  vert[U] = texcoords[2 * i + 0];
@@ -10661,31 +10703,32 @@ public class PGraphicsOpenGL extends PGraphics {
10661
10703
  polyEmissive[tessIdx] = in.emissive[inIdx];
10662
10704
  polyShininess[tessIdx] = in.shininess[inIdx];
10663
10705
 
10664
- for (String name: polyAttribs.keySet()) {
10706
+ polyAttribs.keySet().forEach((name) -> {
10665
10707
  VertexAttribute attrib = polyAttribs.get(name);
10666
- if (attrib.isPosition() || attrib.isNormal()) continue;
10667
- int index0 = attrib.size * inIdx;
10668
- int index1 = attrib.size * tessIdx;
10669
- if (attrib.isFloat()) {
10670
- float[] inValues = in.fattribs.get(name);
10671
- float[] tessValues = fpolyAttribs.get(name);
10672
- for (int n = 0; n < attrib.size; n++) {
10673
- tessValues[index1++] = inValues[index0++];
10674
- }
10675
- } else if (attrib.isInt()) {
10676
- int[] inValues = in.iattribs.get(name);
10677
- int[] tessValues = ipolyAttribs.get(name);
10678
- for (int n = 0; n < attrib.size; n++) {
10679
- tessValues[index1++] = inValues[index0++];
10680
- }
10681
- } else if (attrib.isBool()) {
10682
- byte[] inValues = in.battribs.get(name);
10683
- byte[] tessValues = bpolyAttribs.get(name);
10684
- for (int n = 0; n < attrib.size; n++) {
10685
- tessValues[index1++] = inValues[index0++];
10708
+ if (!(attrib.isPosition() || attrib.isNormal())) {
10709
+ int index0 = attrib.size * inIdx;
10710
+ int index1 = attrib.size * tessIdx;
10711
+ if (attrib.isFloat()) {
10712
+ float[] inValues = in.fattribs.get(name);
10713
+ float[] tessValues = fpolyAttribs.get(name);
10714
+ for (int n = 0; n < attrib.size; n++) {
10715
+ tessValues[index1++] = inValues[index0++];
10716
+ }
10717
+ } else if (attrib.isInt()) {
10718
+ int[] inValues = in.iattribs.get(name);
10719
+ int[] tessValues = ipolyAttribs.get(name);
10720
+ for (int n = 0; n < attrib.size; n++) {
10721
+ tessValues[index1++] = inValues[index0++];
10722
+ }
10723
+ } else if (attrib.isBool()) {
10724
+ byte[] inValues = in.battribs.get(name);
10725
+ byte[] tessValues = bpolyAttribs.get(name);
10726
+ for (int n = 0; n < attrib.size; n++) {
10727
+ tessValues[index1++] = inValues[index0++];
10728
+ }
10686
10729
  }
10687
10730
  }
10688
- }
10731
+ });
10689
10732
  }
10690
10733
  }
10691
10734
 
@@ -12910,7 +12953,7 @@ public class PGraphicsOpenGL extends PGraphics {
12910
12953
  r[j++] = (fcol >> 24) & 0xFF; // fa
12911
12954
  r[j++] = (fcol >> 16) & 0xFF; // fr
12912
12955
  r[j++] = (fcol >> 8) & 0xFF; // fg
12913
- r[j++] = (fcol >> 0) & 0xFF; // fb
12956
+ r[j++] = (fcol) & 0xFF; // fb
12914
12957
 
12915
12958
  r[j++] = in.normals[3*i + 0]; // nx
12916
12959
  r[j++] = in.normals[3*i + 1]; // ny
@@ -13135,6 +13178,7 @@ public class PGraphicsOpenGL extends PGraphics {
13135
13178
  }
13136
13179
  }
13137
13180
 
13181
+ @Override
13138
13182
  public void begin(int type) {
13139
13183
  cacheIndex = cache.getLast();
13140
13184
  if (firstPolyIndexCache == -1) {
@@ -13153,6 +13197,7 @@ public class PGraphicsOpenGL extends PGraphics {
13153
13197
  else if (type == PGL.TRIANGLES) primitive = TRIANGLES;
13154
13198
  }
13155
13199
 
13200
+ @Override
13156
13201
  public void end() {
13157
13202
  if (PGL.MAX_VERTEX_INDEX1 <= vertFirst + vertCount) {
13158
13203
  // We need a new index block for the new batch of
@@ -13228,6 +13273,7 @@ public class PGraphicsOpenGL extends PGraphics {
13228
13273
  vertFirst + vertOffset + tessIdx2);
13229
13274
  }
13230
13275
 
13276
+ @Override
13231
13277
  public void vertex(Object data) {
13232
13278
  if (data instanceof double[]) {
13233
13279
  double[] d = (double[]) data;