From c95f64df26476f49ad9886e54b11afd2304108bf Mon Sep 17 00:00:00 2001 From: codeanticode Date: Mon, 30 Mar 2015 22:27:00 -0400 Subject: [PATCH] init attrib arrays --- .../processing/opengl/PGraphicsOpenGL.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/core/src/processing/opengl/PGraphicsOpenGL.java b/core/src/processing/opengl/PGraphicsOpenGL.java index 15be61137..e62ac1ed6 100644 --- a/core/src/processing/opengl/PGraphicsOpenGL.java +++ b/core/src/processing/opengl/PGraphicsOpenGL.java @@ -2295,6 +2295,8 @@ public class PGraphicsOpenGL extends PGraphics { if (attrib == null) { attrib = new VertexAttribute(name, type, size); attribs.put(name, attrib); + inGeo.initAttrib(attrib); + tessGeo.initAttrib(attrib); } if (attrib.size != size) { PGraphics.showWarning("New value for vertex attribute has wrong number of values"); @@ -7482,6 +7484,19 @@ public class PGraphicsOpenGL extends PGraphics { clear(); } + void initAttrib(VertexAttribute attrib) { + if (attrib.type == PGL.FLOAT) { + float[] temp = new float[attrib.size * PGL.DEFAULT_IN_VERTICES]; + fattribs.put(attrib.name, temp); + } else if (attrib.type == PGL.INT) { + int[] temp = new int[attrib.size * PGL.DEFAULT_IN_VERTICES]; + iattribs.put(attrib.name, temp); + } else if (attrib.type == PGL.BOOL) { + byte[] temp = new byte[attrib.size * PGL.DEFAULT_IN_VERTICES]; + battribs.put(attrib.name, temp); + } + } + void vertexCheck() { if (vertexCount == vertices.length / 3) { int newSize = vertexCount << 1; @@ -8986,6 +9001,22 @@ public class PGraphicsOpenGL extends PGraphics { clear(); } + void initAttrib(VertexAttribute attrib) { + if (attrib.type == PGL.FLOAT) { + float[] temp = new float[attrib.tessSize * PGL.DEFAULT_TESS_VERTICES]; + fattribs.put(attrib.name, temp); + attribBuffers.put(attrib.name, PGL.allocateFloatBuffer(temp)); + } else if (attrib.type == PGL.INT) { + int[] temp = new int[attrib.tessSize * PGL.DEFAULT_TESS_VERTICES]; + iattribs.put(attrib.name, temp); + attribBuffers.put(attrib.name, PGL.allocateIntBuffer(temp)); + } else if (attrib.type == PGL.BOOL) { + byte[] temp = new byte[attrib.tessSize * PGL.DEFAULT_TESS_VERTICES]; + battribs.put(attrib.name, temp); + attribBuffers.put(attrib.name, PGL.allocateByteBuffer(temp)); + } + } + void clear() { firstPolyVertex = lastPolyVertex = polyVertexCount = 0; firstPolyIndex = lastPolyIndex = polyIndexCount = 0;