diff --git a/android/core/src/processing/core/PGL.java b/android/core/src/processing/core/PGL.java index 7fc7a1b49..cb7e2399b 100644 --- a/android/core/src/processing/core/PGL.java +++ b/android/core/src/processing/core/PGL.java @@ -583,18 +583,6 @@ public class PGL { return temp[0]; } - public int getMaxVertices() { - int temp[] = new int[1]; - gl.glGetIntegerv(GL10.GL_MAX_ELEMENTS_VERTICES, temp, 0); - return temp[0]; - } - - public int getMaxIndices() { - int temp[] = new int[1]; - gl.glGetIntegerv(GL10.GL_MAX_ELEMENTS_INDICES, temp, 0); - return temp[0]; - } - public void getNumSamples(int[] num) { num[0] = 1; } diff --git a/android/core/src/processing/core/PGraphicsAndroid3D.java b/android/core/src/processing/core/PGraphicsAndroid3D.java index 207b2a958..1dee076cc 100644 --- a/android/core/src/processing/core/PGraphicsAndroid3D.java +++ b/android/core/src/processing/core/PGraphicsAndroid3D.java @@ -31,7 +31,6 @@ import java.util.HashSet; import java.util.Stack; import javax.microedition.khronos.opengles.*; - // drawPixels is missing...calls to glDrawPixels are commented out // setRasterPos() is also commented out @@ -1876,10 +1875,13 @@ public class PGraphicsAndroid3D extends PGraphics { if (flushMode == FLUSH_CONTINUOUSLY || (flushMode == FLUSH_WHEN_FULL && tessGeo.isFull())) { - // Flushing this current shape either because we are in the flush-after-shape, - // or the tess buffer is full. + + if (flushMode == FLUSH_WHEN_FULL && tessGeo.isOverflow()) { + PGraphics.showWarning("P3D: tessellated arrays are overflowing"); + } + flush(); - } + } } @@ -6852,9 +6854,18 @@ public class PGraphicsAndroid3D extends PGraphics { return PGL.MAX_TESS_VERTICES <= fillVertexCount || PGL.MAX_TESS_VERTICES <= lineVertexCount || PGL.MAX_TESS_VERTICES <= pointVertexCount || - PGL.MAX_TESS_INDICES <= fillIndexCount || - PGL.MAX_TESS_INDICES <= fillIndexCount || - PGL.MAX_TESS_INDICES <= fillIndexCount; + PGL.MAX_TESS_INDICES <= fillIndexCount || + PGL.MAX_TESS_INDICES <= fillIndexCount || + PGL.MAX_TESS_INDICES <= fillIndexCount; + } + + public boolean isOverflow() { + return PGL.MAX_TESS_VERTICES < fillVertexCount || + PGL.MAX_TESS_VERTICES < lineVertexCount || + PGL.MAX_TESS_VERTICES < pointVertexCount || + PGL.MAX_TESS_INDICES < fillIndexCount || + PGL.MAX_TESS_INDICES < fillIndexCount || + PGL.MAX_TESS_INDICES < fillIndexCount; } public void addCounts(TessGeometry other) { diff --git a/java/libraries/opengl/src/processing/opengl/PGL.java b/java/libraries/opengl/src/processing/opengl/PGL.java index 7c5a462b1..4ae2c3da7 100644 --- a/java/libraries/opengl/src/processing/opengl/PGL.java +++ b/java/libraries/opengl/src/processing/opengl/PGL.java @@ -102,7 +102,7 @@ public class PGL { public static final int DEFAULT_VERTEX_CACHE_SIZE = 128; /** Maximum number of tessellated vertices, using 2^20 for Mac/PC. */ - public static final int MAX_TESS_VERTICES = 1048576; + public static final int MAX_TESS_VERTICES = 524288; /** Maximum number of indices. 2 times the max number of * vertices to have good room for vertex reuse. */ @@ -577,18 +577,6 @@ public class PGL { return temp[0]; } - public int getMaxVertices() { - int temp[] = new int[1]; - gl.glGetIntegerv(GL2.GL_MAX_ELEMENTS_VERTICES, temp, 0); - return temp[0]; - } - - public int getMaxIndices() { - int temp[] = new int[1]; - gl.glGetIntegerv(GL2.GL_MAX_ELEMENTS_INDICES, temp, 0); - return temp[0]; - } - public void getNumSamples(int[] num) { gl.glGetIntegerv(GL.GL_SAMPLES, num, 0); } diff --git a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java index b4cddffa3..a86d34590 100644 --- a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java +++ b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java @@ -1886,8 +1886,11 @@ public class PGraphicsOpenGL extends PGraphics { if (flushMode == FLUSH_CONTINUOUSLY || (flushMode == FLUSH_WHEN_FULL && tessGeo.isFull())) { - // Flushing this current shape either because we are in the flush-after-shape, - // or the tess buffer is full. + + if (flushMode == FLUSH_WHEN_FULL && tessGeo.isOverflow()) { + PGraphics.showWarning("P3D: tessellated arrays are overflowing"); + } + flush(); } } @@ -6862,11 +6865,20 @@ public class PGraphicsOpenGL extends PGraphics { return PGL.MAX_TESS_VERTICES <= fillVertexCount || PGL.MAX_TESS_VERTICES <= lineVertexCount || PGL.MAX_TESS_VERTICES <= pointVertexCount || - PGL.MAX_TESS_INDICES <= fillIndexCount || - PGL.MAX_TESS_INDICES <= fillIndexCount || - PGL.MAX_TESS_INDICES <= fillIndexCount; + PGL.MAX_TESS_INDICES <= fillIndexCount || + PGL.MAX_TESS_INDICES <= fillIndexCount || + PGL.MAX_TESS_INDICES <= fillIndexCount; } - + + public boolean isOverflow() { + return PGL.MAX_TESS_VERTICES < fillVertexCount || + PGL.MAX_TESS_VERTICES < lineVertexCount || + PGL.MAX_TESS_VERTICES < pointVertexCount || + PGL.MAX_TESS_INDICES < fillIndexCount || + PGL.MAX_TESS_INDICES < fillIndexCount || + PGL.MAX_TESS_INDICES < fillIndexCount; + } + public void addCounts(TessGeometry other) { fillVertexCount += other.fillVertexCount; fillIndexCount += other.fillIndexCount;