mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Checking for vertex overflows in immediate mode
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user