From ce64c2e5ff02a1f01ed2294a9f39b8fd95f4202e Mon Sep 17 00:00:00 2001 From: codeanticode Date: Sat, 31 Mar 2012 19:42:16 +0000 Subject: [PATCH] Fixed context and edge init in PShape3D --- .../processing/opengl/PGraphicsOpenGL.java | 7 +++++++ .../core/src/processing/opengl/PShape3D.java | 20 ++++++++++--------- .../processing/opengl/PGraphicsOpenGL.java | 7 +++++++ .../src/processing/opengl/PShape3D.java | 20 ++++++++++--------- 4 files changed, 36 insertions(+), 18 deletions(-) diff --git a/android/core/src/processing/opengl/PGraphicsOpenGL.java b/android/core/src/processing/opengl/PGraphicsOpenGL.java index 62be76126..3c51e6ee3 100644 --- a/android/core/src/processing/opengl/PGraphicsOpenGL.java +++ b/android/core/src/processing/opengl/PGraphicsOpenGL.java @@ -6111,6 +6111,7 @@ public class PGraphicsOpenGL extends PGraphics { public int[] emissive; public float[] shininess; + // TODO: this should probably go in the TessGeometry class public int[][] edges; // For later, to be used by libraries... @@ -6127,6 +6128,12 @@ public class PGraphicsOpenGL extends PGraphics { edgeCount = firstEdge = lastEdge = 0; } + + public void clearEdges() { + edgeCount = firstEdge = lastEdge = 0; + } + + public void allocate() { codes = new int[PGL.DEFAULT_IN_VERTICES]; vertices = new float[3 * PGL.DEFAULT_IN_VERTICES]; diff --git a/android/core/src/processing/opengl/PShape3D.java b/android/core/src/processing/opengl/PShape3D.java index 320cf9358..6b4b2e93d 100644 --- a/android/core/src/processing/opengl/PShape3D.java +++ b/android/core/src/processing/opengl/PShape3D.java @@ -2457,6 +2457,7 @@ public class PShape3D extends PShape { } else { if (shapeEnded) { if (tessellated) { + in.clearEdges(); tess.clear(); } @@ -2825,6 +2826,8 @@ public class PShape3D extends PShape { aggregateImpl(); + context = pgl.getContext(); + // Now that we know, we can initialize the buffers with the correct size. if (0 < tess.fillVertexCount && 0 < tess.fillIndexCount) { initFillBuffers(tess.fillVertexCount, tess.fillIndexCount); @@ -3073,8 +3076,6 @@ public class PShape3D extends PShape { int sizei = nvert * PGL.SIZEOF_INT; int sizex = nind * PGL.SIZEOF_INDEX; - context = pgl.getContext(); - glFillVertexBufferID = pg.createVertexBufferObject(); pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillVertexBufferID); pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 3 * sizef, null, glMode); @@ -4126,13 +4127,14 @@ public class PShape3D extends PShape { protected BufferedReader getBufferedReader(String filename) { //BufferedReader retval = papplet.createReader(filename); - BufferedReader retval = null; - if (retval != null) { - return retval; - } else { - PApplet.println("Could not find this file " + filename); - return null; - } +// BufferedReader retval = null; +// if (retval != null) { +// return retval; +// } else { +// PApplet.println("Could not find this file " + filename); +// return null; +// } + return null; } diff --git a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java index fd06eec9a..d5000f5a0 100644 --- a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java +++ b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java @@ -6122,6 +6122,7 @@ public class PGraphicsOpenGL extends PGraphics { public int[] emissive; public float[] shininess; + // TODO: this should probably go in the TessGeometry class public int[][] edges; // For later, to be used by libraries... @@ -6138,6 +6139,12 @@ public class PGraphicsOpenGL extends PGraphics { edgeCount = firstEdge = lastEdge = 0; } + + public void clearEdges() { + edgeCount = firstEdge = lastEdge = 0; + } + + public void allocate() { codes = new int[PGL.DEFAULT_IN_VERTICES]; vertices = new float[3 * PGL.DEFAULT_IN_VERTICES]; diff --git a/java/libraries/opengl/src/processing/opengl/PShape3D.java b/java/libraries/opengl/src/processing/opengl/PShape3D.java index 525317164..7ca1d97bd 100644 --- a/java/libraries/opengl/src/processing/opengl/PShape3D.java +++ b/java/libraries/opengl/src/processing/opengl/PShape3D.java @@ -2468,6 +2468,7 @@ public class PShape3D extends PShape { } else { if (shapeEnded) { if (tessellated) { + in.clearEdges(); tess.clear(); } @@ -2836,6 +2837,8 @@ public class PShape3D extends PShape { aggregateImpl(); + context = pgl.getContext(); + // Now that we know, we can initialize the buffers with the correct size. if (0 < tess.fillVertexCount && 0 < tess.fillIndexCount) { initFillBuffers(tess.fillVertexCount, tess.fillIndexCount); @@ -3084,8 +3087,6 @@ public class PShape3D extends PShape { int sizei = nvert * PGL.SIZEOF_INT; int sizex = nind * PGL.SIZEOF_INDEX; - context = pgl.getContext(); - glFillVertexBufferID = pg.createVertexBufferObject(); pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillVertexBufferID); pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 3 * sizef, null, glMode); @@ -4137,13 +4138,14 @@ public class PShape3D extends PShape { protected BufferedReader getBufferedReader(String filename) { //BufferedReader retval = papplet.createReader(filename); - BufferedReader retval = null; - if (retval != null) { - return retval; - } else { - PApplet.println("Could not find this file " + filename); - return null; - } +// BufferedReader retval = null; +// if (retval != null) { +// return retval; +// } else { +// PApplet.println("Could not find this file " + filename); +// return null; +// } + return null; }