diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index dae300ac2..6f9733a7c 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -11088,8 +11088,8 @@ public class PApplet extends Applet * * @webref image:loading_displaying * @param img the image to display - * @param x x-coordinate of the image - * @param y y-coordinate of the image + * @param a x-coordinate of the image + * @param b y-coordinate of the image * @see PApplet#loadImage(String, String) * @see PImage * @see PGraphics#imageMode(int) @@ -11097,9 +11097,9 @@ public class PApplet extends Applet * @see PGraphics#background(float, float, float, float) * @see PGraphics#alpha(int) */ - public void image(PImage img, float x, float y) { - if (recorder != null) recorder.image(img, x, y); - g.image(img, x, y); + public void image(PImage img, float a, float b) { + if (recorder != null) recorder.image(img, a, b); + g.image(img, a, b); } diff --git a/core/src/processing/core/PConstants.java b/core/src/processing/core/PConstants.java index 1c6f07ae2..e9e49c6b9 100644 --- a/core/src/processing/core/PConstants.java +++ b/core/src/processing/core/PConstants.java @@ -452,10 +452,10 @@ public interface PConstants { // shaders - static public final int FILL_SHADER_SIMPLE = 0; - static public final int FILL_SHADER_LIT = 1; - static public final int FILL_SHADER_TEX = 2; - static public final int FILL_SHADER_FULL = 3; + static public final int POLY_SHADER_SIMPLE = 0; + static public final int POLY_SHADER_LIT = 1; + static public final int POLY_SHADER_TEX = 2; + static public final int POLY_SHADER_FULL = 3; static public final int LINE_SHADER = 4; static public final int POINT_SHADER = 5; diff --git a/java/libraries/opengl/src/processing/opengl/LineShaderFrag.glsl b/java/libraries/opengl/src/processing/opengl/LineShaderFrag.glsl index 8c22a6ac5..3f164b9b1 100644 --- a/java/libraries/opengl/src/processing/opengl/LineShaderFrag.glsl +++ b/java/libraries/opengl/src/processing/opengl/LineShaderFrag.glsl @@ -1,12 +1,11 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2011 Andres Colubri + Copyright (c) 20011-12 Ben Fry and Casey Reas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + License version 2.1 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -17,8 +16,8 @@ Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - + */ + #ifdef GL_ES precision mediump float; precision mediump int; diff --git a/java/libraries/opengl/src/processing/opengl/LineShaderVert.glsl b/java/libraries/opengl/src/processing/opengl/LineShaderVert.glsl index 650d7ed37..cad7868fb 100644 --- a/java/libraries/opengl/src/processing/opengl/LineShaderVert.glsl +++ b/java/libraries/opengl/src/processing/opengl/LineShaderVert.glsl @@ -1,14 +1,11 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2011 Andres Colubri - Based on glsl code from the dpix library: - http://gfx.cs.princeton.edu/proj/dpix/ + Copyright (c) 20011-12 Ben Fry and Casey Reas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + License version 2.1 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -19,7 +16,7 @@ Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + */ uniform mat4 modelviewMatrix; uniform mat4 projectionMatrix; diff --git a/java/libraries/opengl/src/processing/opengl/PFontTexture.java b/java/libraries/opengl/src/processing/opengl/PFontTexture.java index 1b18f181e..93ef2d24e 100644 --- a/java/libraries/opengl/src/processing/opengl/PFontTexture.java +++ b/java/libraries/opengl/src/processing/opengl/PFontTexture.java @@ -3,8 +3,7 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2011 Andres Colubri - Copyright (c) 2004-08 Ben Fry and Casey Reas + Copyright (c) 2011-12 Ben Fry and Casey Reas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public diff --git a/java/libraries/opengl/src/processing/opengl/PFramebuffer.java b/java/libraries/opengl/src/processing/opengl/PFramebuffer.java index e44ccac07..52610130d 100644 --- a/java/libraries/opengl/src/processing/opengl/PFramebuffer.java +++ b/java/libraries/opengl/src/processing/opengl/PFramebuffer.java @@ -3,12 +3,12 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2011 Andres Colubri - Copyright (c) 2010 Ben Fry and Casey Reas + Copyright (c) 2011-12 Ben Fry and Casey Reas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public - License version 2.1 as published by the Free Software Foundation. + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -19,7 +19,7 @@ Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ +*/ package processing.opengl; diff --git a/java/libraries/opengl/src/processing/opengl/PGL.java b/java/libraries/opengl/src/processing/opengl/PGL.java index 71fdb95cc..4359ee071 100644 --- a/java/libraries/opengl/src/processing/opengl/PGL.java +++ b/java/libraries/opengl/src/processing/opengl/PGL.java @@ -3,12 +3,12 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2011 Andres Colubri - Copyright (c) 2010 Ben Fry and Casey Reas + Copyright (c) 2011-12 Ben Fry and Casey Reas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public - License version 2.1 as published by the Free Software Foundation. + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -19,7 +19,7 @@ Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ +*/ package processing.opengl; diff --git a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java index 805f559d3..1e53dc111 100644 --- a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java +++ b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java @@ -74,22 +74,27 @@ public class PGraphicsOpenGL extends PGraphics { /** Current flush mode. */ protected int flushMode = FLUSH_WHEN_FULL; + + /** Types of polygon vertices. */ + static protected final int FILL_VERTEX = 0; + static protected final int LINE_VERTEX = 1; + static protected final int POINT_VERTEX = 2; // ........................................................ // VBOs for immediate rendering: - public int glFillVertexBufferID; - public int glFillColorBufferID; - public int glFillNormalBufferID; - public int glFillTexCoordBufferID; - public int glFillAmbientBufferID; - public int glFillSpecularBufferID; - public int glFillEmissiveBufferID; - public int glFillShininessBufferID; - public int glFillIndexBufferID; - protected boolean fillBuffersCreated = false; - protected PGL.Context fillBuffersContext; + public int glPolyVertexBufferID; + public int glPolyColorBufferID; + public int glPolyNormalBufferID; + public int glPolyTexcoordBufferID; + public int glPolyAmbientBufferID; + public int glPolySpecularBufferID; + public int glPolyEmissiveBufferID; + public int glPolyShininessBufferID; + public int glPolyIndexBufferID; + protected boolean polyBuffersCreated = false; + protected PGL.Context polyBuffersContext; public int glLineVertexBufferID; public int glLineColorBufferID; @@ -152,28 +157,28 @@ public class PGraphicsOpenGL extends PGraphics { // Shaders - static protected URL defFillShaderVertSimpleURL = PGraphicsOpenGL.class.getResource("FillShaderVertSimple.glsl"); - static protected URL defFillShaderVertTexURL = PGraphicsOpenGL.class.getResource("FillShaderVertTex.glsl"); - static protected URL defFillShaderVertLitURL = PGraphicsOpenGL.class.getResource("FillShaderVertLit.glsl"); - static protected URL defFillShaderVertFullURL = PGraphicsOpenGL.class.getResource("FillShaderVertFull.glsl"); - static protected URL defFillShaderFragNoTexURL = PGraphicsOpenGL.class.getResource("FillShaderFragNoTex.glsl"); - static protected URL defFillShaderFragTexURL = PGraphicsOpenGL.class.getResource("FillShaderFragTex.glsl"); + static protected URL defPolyShaderVertSimpleURL = PGraphicsOpenGL.class.getResource("PolyShaderVertSimple.glsl"); + static protected URL defPolyShaderVertTexURL = PGraphicsOpenGL.class.getResource("PolyShaderVertTex.glsl"); + static protected URL defPolyShaderVertLitURL = PGraphicsOpenGL.class.getResource("PolyShaderVertLit.glsl"); + static protected URL defPolyShaderVertFullURL = PGraphicsOpenGL.class.getResource("PolyShaderVertFull.glsl"); + static protected URL defPolyShaderFragNoTexURL = PGraphicsOpenGL.class.getResource("PolyShaderFragNoTex.glsl"); + static protected URL defPolyShaderFragTexURL = PGraphicsOpenGL.class.getResource("PolyShaderFragTex.glsl"); static protected URL defLineShaderVertURL = PGraphicsOpenGL.class.getResource("LineShaderVert.glsl"); static protected URL defLineShaderFragURL = PGraphicsOpenGL.class.getResource("LineShaderFrag.glsl"); static protected URL defPointShaderVertURL = PGraphicsOpenGL.class.getResource("PointShaderVert.glsl"); static protected URL defPointShaderFragURL = PGraphicsOpenGL.class.getResource("PointShaderFrag.glsl"); - static protected FillShaderSimple defFillShaderSimple; - static protected FillShaderTex defFillShaderTex; - static protected FillShaderLit defFillShaderLit; - static protected FillShaderFull defFillShaderFull; + static protected PolyShaderSimple defPolyShaderSimple; + static protected PolyShaderTex defPolyShaderTex; + static protected PolyShaderLit defPolyShaderLit; + static protected PolyShaderFull defPolyShaderFull; static protected LineShader defLineShader; static protected PointShader defPointShader; - protected FillShaderSimple fillShaderSimple; - protected FillShaderTex fillShaderTex; - protected FillShaderLit fillShaderLit; - protected FillShaderFull fillShaderFull; + protected PolyShaderSimple polyShaderSimple; + protected PolyShaderTex polyShaderTex; + protected PolyShaderLit polyShaderLit; + protected PolyShaderFull polyShaderFull; protected LineShader lineShader; protected PointShader pointShader; @@ -403,15 +408,15 @@ public class PGraphicsOpenGL extends PGraphics { tessGeo = newTessGeometry(IMMEDIATE); texCache = newTexCache(); - glFillVertexBufferID = 0; - glFillColorBufferID = 0; - glFillNormalBufferID = 0; - glFillTexCoordBufferID = 0; - glFillAmbientBufferID = 0; - glFillSpecularBufferID = 0; - glFillEmissiveBufferID = 0; - glFillShininessBufferID = 0; - glFillIndexBufferID = 0; + glPolyVertexBufferID = 0; + glPolyColorBufferID = 0; + glPolyNormalBufferID = 0; + glPolyTexcoordBufferID = 0; + glPolyAmbientBufferID = 0; + glPolySpecularBufferID = 0; + glPolyEmissiveBufferID = 0; + glPolyShininessBufferID = 0; + glPolyIndexBufferID = 0; glLineVertexBufferID = 0; glLineColorBufferID = 0; @@ -510,7 +515,7 @@ public class PGraphicsOpenGL extends PGraphics { public void dispose() { // PGraphics super.dispose(); deleteFinalizedGLResources(); - deleteFillBuffers(); + deletePolyBuffers(); deleteLineBuffers(); deletePointBuffers(); } @@ -1047,142 +1052,142 @@ public class PGraphicsOpenGL extends PGraphics { // FRAME RENDERING - protected void createFillBuffers() { - if (!fillBuffersCreated || fillBuffersContextIsOutdated()) { - fillBuffersContext = pgl.getCurrentContext(); + protected void createPolyBuffers() { + if (!polyBuffersCreated || polyBuffersContextIsOutdated()) { + polyBuffersContext = pgl.getCurrentContext(); int sizef = INIT_VERTEX_BUFFER_SIZE * PGL.SIZEOF_FLOAT; int sizei = INIT_VERTEX_BUFFER_SIZE * PGL.SIZEOF_INT; int sizex = INIT_INDEX_BUFFER_SIZE * PGL.SIZEOF_INDEX; - glFillVertexBufferID = createVertexBufferObject(fillBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillVertexBufferID); + glPolyVertexBufferID = createVertexBufferObject(polyBuffersContext.code()); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyVertexBufferID); pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 3 * sizef, null, PGL.GL_STATIC_DRAW); - glFillColorBufferID = createVertexBufferObject(fillBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillColorBufferID); + glPolyColorBufferID = createVertexBufferObject(polyBuffersContext.code()); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyColorBufferID); pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, null, PGL.GL_STATIC_DRAW); - glFillNormalBufferID = createVertexBufferObject(fillBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillNormalBufferID); + glPolyNormalBufferID = createVertexBufferObject(polyBuffersContext.code()); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyNormalBufferID); pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 3 * sizef, null, PGL.GL_STATIC_DRAW); - glFillTexCoordBufferID = createVertexBufferObject(fillBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillTexCoordBufferID); + glPolyTexcoordBufferID = createVertexBufferObject(polyBuffersContext.code()); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyTexcoordBufferID); pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 2 * sizef, null, PGL.GL_STATIC_DRAW); - glFillAmbientBufferID = pg.createVertexBufferObject(fillBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillAmbientBufferID); + glPolyAmbientBufferID = pg.createVertexBufferObject(polyBuffersContext.code()); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyAmbientBufferID); pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, null, PGL.GL_STATIC_DRAW); - glFillSpecularBufferID = pg.createVertexBufferObject(fillBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillSpecularBufferID); + glPolySpecularBufferID = pg.createVertexBufferObject(polyBuffersContext.code()); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolySpecularBufferID); pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, null, PGL.GL_STATIC_DRAW); - glFillEmissiveBufferID = pg.createVertexBufferObject(fillBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillEmissiveBufferID); + glPolyEmissiveBufferID = pg.createVertexBufferObject(polyBuffersContext.code()); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyEmissiveBufferID); pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, null, PGL.GL_STATIC_DRAW); - glFillShininessBufferID = pg.createVertexBufferObject(fillBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillShininessBufferID); + glPolyShininessBufferID = pg.createVertexBufferObject(polyBuffersContext.code()); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyShininessBufferID); pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizef, null, PGL.GL_STATIC_DRAW); pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); - glFillIndexBufferID = createVertexBufferObject(fillBuffersContext.code()); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, glFillIndexBufferID); + glPolyIndexBufferID = createVertexBufferObject(polyBuffersContext.code()); + pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, glPolyIndexBufferID); pgl.glBufferData(PGL.GL_ELEMENT_ARRAY_BUFFER, sizex, null, PGL.GL_STATIC_DRAW); pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, 0); - fillBuffersCreated = true; + polyBuffersCreated = true; } } - protected void updateFillBuffers(boolean lit, boolean tex) { - createFillBuffers(); + protected void updatePolyBuffers(boolean lit, boolean tex) { + createPolyBuffers(); - int size = tessGeo.fillVertexCount; + int size = tessGeo.polyVertexCount; int sizef = size * PGL.SIZEOF_FLOAT; int sizei = size * PGL.SIZEOF_INT; - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillVertexBufferID); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 4 * sizef, FloatBuffer.wrap(tessGeo.fillVertices, 0, 4 * size), PGL.GL_STATIC_DRAW); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyVertexBufferID); + pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 4 * sizef, FloatBuffer.wrap(tessGeo.polyVertices, 0, 4 * size), PGL.GL_STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillColorBufferID); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.fillColors, 0, size), PGL.GL_STATIC_DRAW); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyColorBufferID); + pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polyColors, 0, size), PGL.GL_STATIC_DRAW); if (lit) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillNormalBufferID); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 3 * sizef, FloatBuffer.wrap(tessGeo.fillNormals, 0, 3 * size), PGL.GL_STATIC_DRAW); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyNormalBufferID); + pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 3 * sizef, FloatBuffer.wrap(tessGeo.polyNormals, 0, 3 * size), PGL.GL_STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillAmbientBufferID); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.fillAmbient, 0, size), PGL.GL_STATIC_DRAW); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyAmbientBufferID); + pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polyAmbient, 0, size), PGL.GL_STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillSpecularBufferID); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.fillSpecular, 0, size), PGL.GL_STATIC_DRAW); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolySpecularBufferID); + pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polySpecular, 0, size), PGL.GL_STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillEmissiveBufferID); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.fillEmissive, 0, size), PGL.GL_STATIC_DRAW); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyEmissiveBufferID); + pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polyEmissive, 0, size), PGL.GL_STATIC_DRAW); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillShininessBufferID); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizef, FloatBuffer.wrap(tessGeo.fillShininess, 0, size), PGL.GL_STATIC_DRAW); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyShininessBufferID); + pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizef, FloatBuffer.wrap(tessGeo.polyShininess, 0, size), PGL.GL_STATIC_DRAW); } if (tex) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillTexCoordBufferID); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 2 * sizef, FloatBuffer.wrap(tessGeo.fillTexcoords, 0, 2 * size), PGL.GL_STATIC_DRAW); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyTexcoordBufferID); + pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 2 * sizef, FloatBuffer.wrap(tessGeo.polyTexcoords, 0, 2 * size), PGL.GL_STATIC_DRAW); } - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, glFillIndexBufferID); - pgl.glBufferData(PGL.GL_ELEMENT_ARRAY_BUFFER, tessGeo.fillIndexCount * PGL.SIZEOF_INDEX, - ShortBuffer.wrap(tessGeo.fillIndices, 0, tessGeo.fillIndexCount), PGL.GL_STATIC_DRAW); + pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, glPolyIndexBufferID); + pgl.glBufferData(PGL.GL_ELEMENT_ARRAY_BUFFER, tessGeo.polyIndexCount * PGL.SIZEOF_INDEX, + ShortBuffer.wrap(tessGeo.polyIndices, 0, tessGeo.polyIndexCount), PGL.GL_STATIC_DRAW); } - protected void unbindFillBuffers() { + protected void unbindPolyBuffers() { pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, 0); } - protected boolean fillBuffersContextIsOutdated() { - return !pgl.contextIsCurrent(fillBuffersContext); + protected boolean polyBuffersContextIsOutdated() { + return !pgl.contextIsCurrent(polyBuffersContext); } - protected void deleteFillBuffers() { - if (fillBuffersCreated) { - deleteVertexBufferObject(glFillVertexBufferID, fillBuffersContext.code()); - glFillVertexBufferID = 0; + protected void deletePolyBuffers() { + if (polyBuffersCreated) { + deleteVertexBufferObject(glPolyVertexBufferID, polyBuffersContext.code()); + glPolyVertexBufferID = 0; - deleteVertexBufferObject(glFillColorBufferID, fillBuffersContext.code()); - glFillColorBufferID = 0; + deleteVertexBufferObject(glPolyColorBufferID, polyBuffersContext.code()); + glPolyColorBufferID = 0; - deleteVertexBufferObject(glFillNormalBufferID, fillBuffersContext.code()); - glFillNormalBufferID = 0; + deleteVertexBufferObject(glPolyNormalBufferID, polyBuffersContext.code()); + glPolyNormalBufferID = 0; - deleteVertexBufferObject(glFillTexCoordBufferID, fillBuffersContext.code()); - glFillTexCoordBufferID = 0; + deleteVertexBufferObject(glPolyTexcoordBufferID, polyBuffersContext.code()); + glPolyTexcoordBufferID = 0; - deleteVertexBufferObject(glFillAmbientBufferID, fillBuffersContext.code()); - glFillAmbientBufferID = 0; + deleteVertexBufferObject(glPolyAmbientBufferID, polyBuffersContext.code()); + glPolyAmbientBufferID = 0; - deleteVertexBufferObject(glFillSpecularBufferID, fillBuffersContext.code()); - glFillSpecularBufferID = 0; + deleteVertexBufferObject(glPolySpecularBufferID, polyBuffersContext.code()); + glPolySpecularBufferID = 0; - deleteVertexBufferObject(glFillEmissiveBufferID, fillBuffersContext.code()); - glFillEmissiveBufferID = 0; + deleteVertexBufferObject(glPolyEmissiveBufferID, polyBuffersContext.code()); + glPolyEmissiveBufferID = 0; - deleteVertexBufferObject(glFillShininessBufferID, fillBuffersContext.code()); - glFillShininessBufferID = 0; + deleteVertexBufferObject(glPolyShininessBufferID, polyBuffersContext.code()); + glPolyShininessBufferID = 0; - deleteVertexBufferObject(glFillIndexBufferID, fillBuffersContext.code()); - glFillIndexBufferID = 0; + deleteVertexBufferObject(glPolyIndexBufferID, polyBuffersContext.code()); + glPolyIndexBufferID = 0; - fillBuffersCreated = false; + polyBuffersCreated = false; } } @@ -2375,7 +2380,7 @@ public class PGraphicsOpenGL extends PGraphics { public void flush() { boolean hasPoints = 0 < tessGeo.pointVertexCount && 0 < tessGeo.pointIndexCount; boolean hasLines = 0 < tessGeo.lineVertexCount && 0 < tessGeo.lineIndexCount; - boolean hasFill = 0 < tessGeo.fillVertexCount && 0 < tessGeo.fillIndexCount; + boolean hasPolys = 0 < tessGeo.polyVertexCount && 0 < tessGeo.polyIndexCount; boolean hasPixels = modified && pixels != null; if (hasPixels) { @@ -2386,7 +2391,7 @@ public class PGraphicsOpenGL extends PGraphics { setgetPixels = false; } - if (hasPoints || hasLines || hasFill) { + if (hasPoints || hasLines || hasPolys) { if (flushMode == FLUSH_WHEN_FULL && !hints[DISABLE_TRANSFORM_CACHE]) { // The modelview transformation has been applied already to the // tessellated vertices, so we set the OpenGL modelview matrix as @@ -2395,10 +2400,10 @@ public class PGraphicsOpenGL extends PGraphics { resetMatrix(); } - if (hasFill) { - flushFill(); + if (hasPolys) { + flushPolys(); if (raw != null) { - rawFill(); + rawPolys(); } } @@ -2613,19 +2618,19 @@ public class PGraphicsOpenGL extends PGraphics { } - protected void flushFill() { - updateFillBuffers(lights, texCache.haveTexture); + protected void flushPolys() { + updatePolyBuffers(lights, texCache.haveTexture); texCache.beginRender(); for (int i = 0; i < texCache.size; i++) { PTexture tex = texCache.getTexture(i); - FillShader shader = getFillShader(lights, tex != null); + PolyShader shader = getPolyShader(lights, tex != null); shader.start(); int first = texCache.firstCache[i]; int last = texCache.lastCache[i]; - IndexCache cache = tessGeo.fillIndexCache; + IndexCache cache = tessGeo.polyIndexCache; for (int n = first; n <= last; n++) { int ioffset = n == first ? texCache.firstIndex[i] : cache.indexOffset[n]; @@ -2633,23 +2638,23 @@ public class PGraphicsOpenGL extends PGraphics { cache.indexOffset[n] + cache.indexCount[n] - ioffset; int voffset = cache.vertexOffset[n]; - shader.setVertexAttribute(glFillVertexBufferID, 4, PGL.GL_FLOAT, 0, 4 * voffset * PGL.SIZEOF_FLOAT); - shader.setColorAttribute(glFillColorBufferID, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); + shader.setVertexAttribute(glPolyVertexBufferID, 4, PGL.GL_FLOAT, 0, 4 * voffset * PGL.SIZEOF_FLOAT); + shader.setColorAttribute(glPolyColorBufferID, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); if (lights) { - shader.setNormalAttribute(glFillNormalBufferID, 3, PGL.GL_FLOAT, 0, 3 * voffset * PGL.SIZEOF_FLOAT); - shader.setAmbientAttribute(glFillAmbientBufferID, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); - shader.setSpecularAttribute(glFillSpecularBufferID, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); - shader.setEmissiveAttribute(glFillEmissiveBufferID, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); - shader.setShininessAttribute(glFillShininessBufferID, 1, PGL.GL_FLOAT, 0, voffset * PGL.SIZEOF_FLOAT); + shader.setNormalAttribute(glPolyNormalBufferID, 3, PGL.GL_FLOAT, 0, 3 * voffset * PGL.SIZEOF_FLOAT); + shader.setAmbientAttribute(glPolyAmbientBufferID, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); + shader.setSpecularAttribute(glPolySpecularBufferID, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); + shader.setEmissiveAttribute(glPolyEmissiveBufferID, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); + shader.setShininessAttribute(glPolyShininessBufferID, 1, PGL.GL_FLOAT, 0, voffset * PGL.SIZEOF_FLOAT); } if (tex != null) { - shader.setTexCoordAttribute(glFillTexCoordBufferID, 2, PGL.GL_FLOAT, 0, 2 * voffset * PGL.SIZEOF_FLOAT); + shader.setTexcoordAttribute(glPolyTexcoordBufferID, 2, PGL.GL_FLOAT, 0, 2 * voffset * PGL.SIZEOF_FLOAT); shader.setTexture(tex); } - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, glFillIndexBufferID); + pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, glPolyIndexBufferID); pgl.glDrawElements(PGL.GL_TRIANGLES, icount, PGL.INDEX_TYPE, ioffset * PGL.SIZEOF_INDEX); pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, 0); } @@ -2657,26 +2662,26 @@ public class PGraphicsOpenGL extends PGraphics { shader.stop(); } texCache.endRender(); - unbindFillBuffers(); + unbindPolyBuffers(); } - void rawFill() { + void rawPolys() { raw.colorMode(RGB); raw.noStroke(); raw.beginShape(TRIANGLES); - float[] vertices = tessGeo.fillVertices; - int[] color = tessGeo.fillColors; - float[] uv = tessGeo.fillTexcoords; - short[] indices = tessGeo.fillIndices; + float[] vertices = tessGeo.polyVertices; + int[] color = tessGeo.polyColors; + float[] uv = tessGeo.polyTexcoords; + short[] indices = tessGeo.polyIndices; for (int i = 0; i < texCache.size; i++) { PImage textureImage = texCache.getTextureImage(i); int first = texCache.firstCache[i]; int last = texCache.lastCache[i]; - IndexCache cache = tessGeo.fillIndexCache; + IndexCache cache = tessGeo.polyIndexCache; for (int n = first; n <= last; n++) { int ioffset = n == first ? texCache.firstIndex[i] : cache.indexOffset[n]; int icount = n == last ? texCache.lastIndex[i] - ioffset + 1 : @@ -5697,14 +5702,14 @@ public class PGraphicsOpenGL extends PGraphics { public PShader loadShader(String vertFilename, String fragFilename, int kind) { - if (kind == FILL_SHADER_SIMPLE) { - return new FillShaderSimple(parent, vertFilename, fragFilename); - } else if (kind == FILL_SHADER_LIT) { - return new FillShaderLit(parent, vertFilename, fragFilename); - } else if (kind == FILL_SHADER_TEX) { - return new FillShaderTex(parent, vertFilename, fragFilename); - } else if (kind == FILL_SHADER_FULL) { - return new FillShaderFull(parent, vertFilename, fragFilename); + if (kind == POLY_SHADER_SIMPLE) { + return new PolyShaderSimple(parent, vertFilename, fragFilename); + } else if (kind == POLY_SHADER_LIT) { + return new PolyShaderLit(parent, vertFilename, fragFilename); + } else if (kind == POLY_SHADER_TEX) { + return new PolyShaderTex(parent, vertFilename, fragFilename); + } else if (kind == POLY_SHADER_FULL) { + return new PolyShaderFull(parent, vertFilename, fragFilename); } else if (kind == LINE_SHADER) { return new LineShader(parent, vertFilename, fragFilename); } else if (kind == POINT_SHADER) { @@ -5718,18 +5723,18 @@ public class PGraphicsOpenGL extends PGraphics { public PShader loadShader(String fragFilename, int kind) { PShader shader; - if (kind == FILL_SHADER_SIMPLE) { - shader = new FillShaderSimple(parent); - shader.setVertexShader(defFillShaderVertSimpleURL); - } else if (kind == FILL_SHADER_LIT) { - shader = new FillShaderLit(parent); - shader.setVertexShader(defFillShaderVertLitURL); - } else if (kind == FILL_SHADER_TEX) { - shader = new FillShaderTex(parent); - shader.setVertexShader(defFillShaderVertTexURL); - } else if (kind == FILL_SHADER_FULL) { - shader = new FillShaderFull(parent); - shader.setVertexShader(defFillShaderVertFullURL); + if (kind == POLY_SHADER_SIMPLE) { + shader = new PolyShaderSimple(parent); + shader.setVertexShader(defPolyShaderVertSimpleURL); + } else if (kind == POLY_SHADER_LIT) { + shader = new PolyShaderLit(parent); + shader.setVertexShader(defPolyShaderVertLitURL); + } else if (kind == POLY_SHADER_TEX) { + shader = new PolyShaderTex(parent); + shader.setVertexShader(defPolyShaderVertTexURL); + } else if (kind == POLY_SHADER_FULL) { + shader = new PolyShaderFull(parent); + shader.setVertexShader(defPolyShaderVertFullURL); } else if (kind == LINE_SHADER) { shader = new LineShader(parent); shader.setVertexShader(defLineShaderVertURL); @@ -5746,14 +5751,14 @@ public class PGraphicsOpenGL extends PGraphics { public void setShader(PShader shader, int kind) { - if (kind == FILL_SHADER_SIMPLE) { - fillShaderSimple = (FillShaderSimple) shader; - } else if (kind == FILL_SHADER_LIT) { - fillShaderLit = (FillShaderLit) shader; - } else if (kind == FILL_SHADER_TEX) { - fillShaderTex = (FillShaderTex) shader; - } else if (kind == FILL_SHADER_FULL) { - fillShaderFull = (FillShaderFull) shader; + if (kind == POLY_SHADER_SIMPLE) { + polyShaderSimple = (PolyShaderSimple) shader; + } else if (kind == POLY_SHADER_LIT) { + polyShaderLit = (PolyShaderLit) shader; + } else if (kind == POLY_SHADER_TEX) { + polyShaderTex = (PolyShaderTex) shader; + } else if (kind == POLY_SHADER_FULL) { + polyShaderFull = (PolyShaderFull) shader; } else if (kind == LINE_SHADER) { lineShader = (LineShader) shader; } else if (kind == POINT_SHADER) { @@ -5765,26 +5770,26 @@ public class PGraphicsOpenGL extends PGraphics { public void resetShader(int kind) { - if (kind == FILL_SHADER_SIMPLE) { - if (defFillShaderSimple == null || defFillShaderSimple.contextIsOutdated()) { - defFillShaderSimple = new FillShaderSimple(parent, defFillShaderVertSimpleURL, defFillShaderFragNoTexURL); + if (kind == POLY_SHADER_SIMPLE) { + if (defPolyShaderSimple == null || defPolyShaderSimple.contextIsOutdated()) { + defPolyShaderSimple = new PolyShaderSimple(parent, defPolyShaderVertSimpleURL, defPolyShaderFragNoTexURL); } - fillShaderSimple = defFillShaderSimple; - } else if (kind == FILL_SHADER_LIT) { - if (defFillShaderLit == null || defFillShaderLit.contextIsOutdated()) { - defFillShaderLit = new FillShaderLit(parent, defFillShaderVertLitURL, defFillShaderFragNoTexURL); + polyShaderSimple = defPolyShaderSimple; + } else if (kind == POLY_SHADER_LIT) { + if (defPolyShaderLit == null || defPolyShaderLit.contextIsOutdated()) { + defPolyShaderLit = new PolyShaderLit(parent, defPolyShaderVertLitURL, defPolyShaderFragNoTexURL); } - fillShaderLit = defFillShaderLit; - } else if (kind == FILL_SHADER_TEX) { - if (defFillShaderTex == null || defFillShaderTex.contextIsOutdated()) { - defFillShaderTex = new FillShaderTex(parent, defFillShaderVertTexURL, defFillShaderFragTexURL); + polyShaderLit = defPolyShaderLit; + } else if (kind == POLY_SHADER_TEX) { + if (defPolyShaderTex == null || defPolyShaderTex.contextIsOutdated()) { + defPolyShaderTex = new PolyShaderTex(parent, defPolyShaderVertTexURL, defPolyShaderFragTexURL); } - fillShaderTex = defFillShaderTex; - } else if (kind == FILL_SHADER_FULL) { - if (defFillShaderFull == null || defFillShaderFull.contextIsOutdated()) { - defFillShaderFull = new FillShaderFull(parent, defFillShaderVertFullURL, defFillShaderFragTexURL); + polyShaderTex = defPolyShaderTex; + } else if (kind == POLY_SHADER_FULL) { + if (defPolyShaderFull == null || defPolyShaderFull.contextIsOutdated()) { + defPolyShaderFull = new PolyShaderFull(parent, defPolyShaderVertFullURL, defPolyShaderFragTexURL); } - fillShaderFull = defFillShaderFull; + polyShaderFull = defPolyShaderFull; } else if (kind == LINE_SHADER) { if (defLineShader == null || defLineShader.contextIsOutdated()) { defLineShader = new LineShader(parent, defLineShaderVertURL, defLineShaderFragURL); @@ -5801,43 +5806,43 @@ public class PGraphicsOpenGL extends PGraphics { } - protected FillShader getFillShader(boolean lit, boolean tex) { - FillShader shader; + protected PolyShader getPolyShader(boolean lit, boolean tex) { + PolyShader shader; if (lit) { if (tex) { - if (defFillShaderFull == null || defFillShaderFull.contextIsOutdated()) { - defFillShaderFull = new FillShaderFull(parent, defFillShaderVertFullURL, defFillShaderFragTexURL); + if (defPolyShaderFull == null || defPolyShaderFull.contextIsOutdated()) { + defPolyShaderFull = new PolyShaderFull(parent, defPolyShaderVertFullURL, defPolyShaderFragTexURL); } - if (fillShaderFull == null || fillShaderFull.contextIsOutdated()) { - fillShaderFull = defFillShaderFull; + if (polyShaderFull == null || polyShaderFull.contextIsOutdated()) { + polyShaderFull = defPolyShaderFull; } - shader = fillShaderFull; + shader = polyShaderFull; } else { - if (defFillShaderLit == null || defFillShaderLit.contextIsOutdated()) { - defFillShaderLit = new FillShaderLit(parent, defFillShaderVertLitURL, defFillShaderFragNoTexURL); + if (defPolyShaderLit == null || defPolyShaderLit.contextIsOutdated()) { + defPolyShaderLit = new PolyShaderLit(parent, defPolyShaderVertLitURL, defPolyShaderFragNoTexURL); } - if (fillShaderLit == null || fillShaderLit.contextIsOutdated()) { - fillShaderLit = defFillShaderLit; + if (polyShaderLit == null || polyShaderLit.contextIsOutdated()) { + polyShaderLit = defPolyShaderLit; } - shader = fillShaderLit; + shader = polyShaderLit; } } else { if (tex) { - if (defFillShaderTex == null || defFillShaderTex.contextIsOutdated()) { - defFillShaderTex = new FillShaderTex(parent, defFillShaderVertTexURL, defFillShaderFragTexURL); + if (defPolyShaderTex == null || defPolyShaderTex.contextIsOutdated()) { + defPolyShaderTex = new PolyShaderTex(parent, defPolyShaderVertTexURL, defPolyShaderFragTexURL); } - if (fillShaderTex == null || fillShaderTex.contextIsOutdated()) { - fillShaderTex = defFillShaderTex; + if (polyShaderTex == null || polyShaderTex.contextIsOutdated()) { + polyShaderTex = defPolyShaderTex; } - shader = fillShaderTex; + shader = polyShaderTex; } else { - if (defFillShaderSimple == null || defFillShaderSimple.contextIsOutdated()) { - defFillShaderSimple = new FillShaderSimple(parent, defFillShaderVertSimpleURL, defFillShaderFragNoTexURL); + if (defPolyShaderSimple == null || defPolyShaderSimple.contextIsOutdated()) { + defPolyShaderSimple = new PolyShaderSimple(parent, defPolyShaderVertSimpleURL, defPolyShaderFragNoTexURL); } - if (fillShaderSimple == null || fillShaderSimple.contextIsOutdated()) { - fillShaderSimple = defFillShaderSimple; + if (polyShaderSimple == null || polyShaderSimple.contextIsOutdated()) { + polyShaderSimple = defPolyShaderSimple; } - shader = fillShaderSimple; + shader = polyShaderSimple; } } shader.setRenderer(this); @@ -5875,22 +5880,22 @@ public class PGraphicsOpenGL extends PGraphics { } - protected class FillShader extends PShader { + protected class PolyShader extends PShader { // We need a reference to the renderer since a shader might // be called by different renderers within a single application // (the one corresponding to the main surface, or other offscreen // renderers). protected PGraphicsOpenGL renderer; - public FillShader(PApplet parent) { + public PolyShader(PApplet parent) { super(parent); } - public FillShader(PApplet parent, String vertFilename, String fragFilename) { + public PolyShader(PApplet parent, String vertFilename, String fragFilename) { super(parent, vertFilename, fragFilename); } - public FillShader(PApplet parent, URL vertURL, URL fragURL) { + public PolyShader(PApplet parent, URL vertURL, URL fragURL) { super(parent, vertURL, fragURL); } @@ -5915,26 +5920,26 @@ public class PGraphicsOpenGL extends PGraphics { public void setSpecularAttribute(int vboId, int size, int type, int stride, int offset) { } public void setEmissiveAttribute(int vboId, int size, int type, int stride, int offset) { } public void setShininessAttribute(int vboId, int size, int type, int stride, int offset) { } - public void setTexCoordAttribute(int vboId, int size, int type, int stride, int offset) { } + public void setTexcoordAttribute(int vboId, int size, int type, int stride, int offset) { } public void setTexture(PTexture tex) { } } - protected class FillShaderSimple extends FillShader { + protected class PolyShaderSimple extends PolyShader { protected int projmodelviewMatrixLoc; protected int inVertexLoc; protected int inColorLoc; - public FillShaderSimple(PApplet parent) { + public PolyShaderSimple(PApplet parent) { super(parent); } - public FillShaderSimple(PApplet parent, String vertFilename, String fragFilename) { + public PolyShaderSimple(PApplet parent, String vertFilename, String fragFilename) { super(parent, vertFilename, fragFilename); } - public FillShaderSimple(PApplet parent, URL vertURL, URL fragURL) { + public PolyShaderSimple(PApplet parent, URL vertURL, URL fragURL) { super(parent, vertURL, fragURL); } @@ -5978,7 +5983,7 @@ public class PGraphicsOpenGL extends PGraphics { } - protected class FillShaderLit extends FillShader { + protected class PolyShaderLit extends PolyShader { protected int projmodelviewMatrixLoc; protected int modelviewMatrixLoc; protected int normalMatrixLoc; @@ -6001,15 +6006,15 @@ public class PGraphicsOpenGL extends PGraphics { protected int inEmissiveLoc; protected int inShineLoc; - public FillShaderLit(PApplet parent) { + public PolyShaderLit(PApplet parent) { super(parent); } - public FillShaderLit(PApplet parent, String vertFilename, String fragFilename) { + public PolyShaderLit(PApplet parent, String vertFilename, String fragFilename) { super(parent, vertFilename, fragFilename); } - public FillShaderLit(PApplet parent, URL vertURL, URL fragURL) { + public PolyShaderLit(PApplet parent, URL vertURL, URL fragURL) { super(parent, vertURL, fragURL); } @@ -6117,7 +6122,7 @@ public class PGraphicsOpenGL extends PGraphics { } - protected class FillShaderTex extends FillShaderSimple { + protected class PolyShaderTex extends PolyShaderSimple { protected int inTexcoordLoc; protected int texcoordMatrixLoc; @@ -6125,15 +6130,15 @@ public class PGraphicsOpenGL extends PGraphics { protected float[] tcmat; - public FillShaderTex(PApplet parent) { + public PolyShaderTex(PApplet parent) { super(parent); } - public FillShaderTex(PApplet parent, String vertFilename, String fragFilename) { + public PolyShaderTex(PApplet parent, String vertFilename, String fragFilename) { super(parent, vertFilename, fragFilename); } - public FillShaderTex(PApplet parent, URL vertURL, URL fragURL) { + public PolyShaderTex(PApplet parent, URL vertURL, URL fragURL) { super(parent, vertURL, fragURL); } @@ -6150,7 +6155,7 @@ public class PGraphicsOpenGL extends PGraphics { inTexcoordLoc = getAttribLocation("inTexcoord"); } - public void setTexCoordAttribute(int vboId, int size, int type, int stride, int offset) { + public void setTexcoordAttribute(int vboId, int size, int type, int stride, int offset) { setAttribute(inTexcoordLoc, vboId, size, type, false, stride, offset); } @@ -6170,10 +6175,10 @@ public class PGraphicsOpenGL extends PGraphics { dispv = 1; } - scaleu *= tex.maxTexCoordU; - dispu *= tex.maxTexCoordU; - scalev *= tex.maxTexCoordV; - dispv *= tex.maxTexCoordV; + scaleu *= tex.maxTexcoordU; + dispu *= tex.maxTexcoordU; + scalev *= tex.maxTexcoordV; + dispv *= tex.maxTexcoordV; if (tcmat == null) { tcmat = new float[16]; @@ -6202,7 +6207,7 @@ public class PGraphicsOpenGL extends PGraphics { } - protected class FillShaderFull extends FillShaderLit { + protected class PolyShaderFull extends PolyShaderLit { protected int inTexcoordLoc; protected int texcoordMatrixLoc; @@ -6210,15 +6215,15 @@ public class PGraphicsOpenGL extends PGraphics { protected float[] tcmat; - public FillShaderFull(PApplet parent) { + public PolyShaderFull(PApplet parent) { super(parent); } - public FillShaderFull(PApplet parent, String vertFilename, String fragFilename) { + public PolyShaderFull(PApplet parent, String vertFilename, String fragFilename) { super(parent, vertFilename, fragFilename); } - public FillShaderFull(PApplet parent, URL vertURL, URL fragURL) { + public PolyShaderFull(PApplet parent, URL vertURL, URL fragURL) { super(parent, vertURL, fragURL); } @@ -6235,7 +6240,7 @@ public class PGraphicsOpenGL extends PGraphics { inTexcoordLoc = getAttribLocation("inTexcoord"); } - public void setTexCoordAttribute(int vboId, int size, int type, int stride, int offset) { + public void setTexcoordAttribute(int vboId, int size, int type, int stride, int offset) { setAttribute(inTexcoordLoc, vboId, size, type, false, stride, offset); } @@ -6255,10 +6260,10 @@ public class PGraphicsOpenGL extends PGraphics { dispv = 1; } - scaleu *= tex.maxTexCoordU; - dispu *= tex.maxTexCoordU; - scalev *= tex.maxTexCoordV; - dispv *= tex.maxTexCoordV; + scaleu *= tex.maxTexcoordU; + dispu *= tex.maxTexcoordU; + scalev *= tex.maxTexcoordV; + dispv *= tex.maxTexcoordV; if (tcmat == null) { tcmat = new float[16]; @@ -6757,6 +6762,7 @@ public class PGraphicsOpenGL extends PGraphics { // This class allows to define a multi-valued mapping // from input to tessellated vertices. protected class TessMap { + /* InGeometry in; TessGeometry tess; @@ -6908,6 +6914,7 @@ public class PGraphicsOpenGL extends PGraphics { void addFillIndex(int inIdx, int tessIdx) { addFillIndex(inIdx, tessIdx, 1); } + */ } // Holds the input vertices: xyz coordinates, fill/tint color, @@ -6929,8 +6936,6 @@ public class PGraphicsOpenGL extends PGraphics { int firstEdge; int lastEdge; - // TODO: use 3 components per vertex, and update copy - // to tess accordindgly. float[] vertices; int[] colors; float[] normals; @@ -6979,7 +6984,7 @@ public class PGraphicsOpenGL extends PGraphics { } void allocate() { - vertices = new float[4 * PGL.DEFAULT_IN_VERTICES]; + vertices = new float[3 * PGL.DEFAULT_IN_VERTICES]; colors = new int[PGL.DEFAULT_IN_VERTICES]; normals = new float[3 * PGL.DEFAULT_IN_VERTICES]; texcoords = new float[2 * PGL.DEFAULT_IN_VERTICES]; @@ -6993,7 +6998,7 @@ public class PGraphicsOpenGL extends PGraphics { edges = new int[PGL.DEFAULT_IN_EDGES][3]; if (renderMode == RETAINED) { - tessMap = new TessMap(); +// tessMap = new TessMap(); } clear(); @@ -7014,12 +7019,12 @@ public class PGraphicsOpenGL extends PGraphics { edges = null; if (renderMode == RETAINED) { - tessMap.dispose(); +// tessMap.dispose(); } } void vertexCheck() { - if (vertexCount == vertices.length / 4) { + if (vertexCount == vertices.length / 3) { int newSize = vertexCount << 1; expandVertices(newSize); @@ -7051,16 +7056,16 @@ public class PGraphicsOpenGL extends PGraphics { void initTessMap(TessGeometry tess) { if (renderMode == RETAINED) { - tessMap.init(this, tess); +// tessMap.init(this, tess); } } void disposeTessMap() { - tessMap.dispose(); +// tessMap.dispose(); } void compactTessMap() { - tessMap.compact(); +// tessMap.compact(); } /* @@ -7093,27 +7098,27 @@ public class PGraphicsOpenGL extends PGraphics { // Query float getVertexX(int idx) { - return vertices[4 * idx + 0]; + return vertices[3 * idx + 0]; } float getVertexY(int idx) { - return vertices[4 * idx + 1]; + return vertices[3 * idx + 1]; } float getVertexZ(int idx) { - return vertices[4 * idx + 2]; + return vertices[3 * idx + 2]; } float getLastVertexX() { - return vertices[4 * (vertexCount - 1) + 0]; + return vertices[3 * (vertexCount - 1) + 0]; } float getLastVertexY() { - return vertices[4 * (vertexCount - 1) + 1]; + return vertices[3 * (vertexCount - 1) + 1]; } float getLastVertexZ() { - return vertices[4 * (vertexCount - 1) + 2]; + return vertices[3 * (vertexCount - 1) + 2]; } int getNumLineVertices() { @@ -7160,8 +7165,8 @@ public class PGraphicsOpenGL extends PGraphics { // Expand arrays void expandVertices(int n) { - float temp[] = new float[4 * n]; - PApplet.arrayCopy(vertices, 0, temp, 0, 4 * vertexCount); + float temp[] = new float[3 * n]; + PApplet.arrayCopy(vertices, 0, temp, 0, 3 * vertexCount); vertices = temp; } @@ -7236,7 +7241,7 @@ public class PGraphicsOpenGL extends PGraphics { // Trim arrays void trim() { - if (0 < vertexCount && vertexCount < vertices.length / 4) { + if (0 < vertexCount && vertexCount < vertices.length / 3) { trimVertices(); trimColors(); trimNormals(); @@ -7256,8 +7261,8 @@ public class PGraphicsOpenGL extends PGraphics { } void trimVertices() { - float temp[] = new float[4 * vertexCount]; - PApplet.arrayCopy(vertices, 0, temp, 0, 4 * vertexCount); + float temp[] = new float[3 * vertexCount]; + PApplet.arrayCopy(vertices, 0, temp, 0, 3 * vertexCount); vertices = temp; } @@ -7389,11 +7394,10 @@ public class PGraphicsOpenGL extends PGraphics { curveVertexCount = 0; - index = 4 * vertexCount; + index = 3 * vertexCount; vertices[index++] = x; vertices[index++] = y; - vertices[index++] = z; - vertices[index ] = 1; + vertices[index ] = z; colors[vertexCount] = PGL.javaToNativeARGB(fcolor); @@ -7697,17 +7701,17 @@ public class PGraphicsOpenGL extends PGraphics { void calcTriangleNormal(int i0, int i1, int i2) { int index; - index = 4 * i0; + index = 3 * i0; float x0 = vertices[index++]; float y0 = vertices[index++]; float z0 = vertices[index ]; - index = 4 * i1; + index = 3 * i1; float x1 = vertices[index++]; float y1 = vertices[index++]; float z1 = vertices[index ]; - index = 4 * i2; + index = 3 * i2; float x2 = vertices[index++]; float y2 = vertices[index++]; float z2 = vertices[index ]; @@ -8340,37 +8344,33 @@ public class PGraphicsOpenGL extends PGraphics { } - // Holds tessellated data for fill, line and point geometry. + // Holds tessellated data for polygon, line and point geometry. protected class TessGeometry { int renderMode; - // Tessellated fill data - // TODO: rename to poly... - int fillVertexCount; - int firstFillVertex; - int lastFillVertex; - float[] fillVertices; - int[] fillColors; - float[] fillNormals; - float[] fillTexcoords; - // Add polyTypes to use in P2D, and classify each poly vertex as: - // FILL_VERTEX - // LINE_VERTEX - // POINT_VERTEX - // while the line and point arrays will remain null. + // Tessellated polygon data + int polyVertexCount; + int firstPolyVertex; + int lastPolyVertex; + float[] polyVertices; + int[] polyColors; + float[] polyNormals; + float[] polyTexcoords; - // Fill material properties (fillColor is used + // Polygon material properties (polyColors is used // as the diffuse color when lighting is enabled) - int[] fillAmbient; - int[] fillSpecular; - int[] fillEmissive; - float[] fillShininess; + int[] polyAmbient; + int[] polySpecular; + int[] polyEmissive; + float[] polyShininess; - int fillIndexCount; - int firstFillIndex; - int lastFillIndex; - short[] fillIndices; - IndexCache fillIndexCache = new IndexCache(); + byte[] polyTypes; + + int polyIndexCount; + int firstPolyIndex; + int lastPolyIndex; + short[] polyIndices; + IndexCache polyIndexCache = new IndexCache(); // Tessellated line data int lineVertexCount; @@ -8410,15 +8410,16 @@ public class PGraphicsOpenGL extends PGraphics { // Allocate/dispose void allocate() { - fillVertices = new float[4 * PGL.DEFAULT_TESS_VERTICES]; - fillColors = new int[PGL.DEFAULT_TESS_VERTICES]; - fillNormals = new float[3 * PGL.DEFAULT_TESS_VERTICES]; - fillTexcoords = new float[2 * PGL.DEFAULT_TESS_VERTICES]; - fillAmbient = new int[PGL.DEFAULT_TESS_VERTICES]; - fillSpecular = new int[PGL.DEFAULT_TESS_VERTICES]; - fillEmissive = new int[PGL.DEFAULT_TESS_VERTICES]; - fillShininess = new float[PGL.DEFAULT_TESS_VERTICES]; - fillIndices = new short[PGL.DEFAULT_TESS_VERTICES]; + polyVertices = new float[4 * PGL.DEFAULT_TESS_VERTICES]; + polyColors = new int[PGL.DEFAULT_TESS_VERTICES]; + polyNormals = new float[3 * PGL.DEFAULT_TESS_VERTICES]; + polyTexcoords = new float[2 * PGL.DEFAULT_TESS_VERTICES]; + polyAmbient = new int[PGL.DEFAULT_TESS_VERTICES]; + polySpecular = new int[PGL.DEFAULT_TESS_VERTICES]; + polyEmissive = new int[PGL.DEFAULT_TESS_VERTICES]; + polyShininess = new float[PGL.DEFAULT_TESS_VERTICES]; + polyTypes = new byte[PGL.DEFAULT_TESS_VERTICES]; + polyIndices = new short[PGL.DEFAULT_TESS_VERTICES]; lineVertices = new float[4 * PGL.DEFAULT_TESS_VERTICES]; lineColors = new int[PGL.DEFAULT_TESS_VERTICES]; @@ -8434,8 +8435,8 @@ public class PGraphicsOpenGL extends PGraphics { } void clear() { - firstFillVertex = lastFillVertex = fillVertexCount = 0; - firstFillIndex = lastFillIndex = fillIndexCount = 0; + firstPolyVertex = lastPolyVertex = polyVertexCount = 0; + firstPolyIndex = lastPolyIndex = polyIndexCount = 0; firstLineVertex = lastLineVertex = lineVertexCount = 0; firstLineIndex = lastLineIndex = lineIndexCount = 0; @@ -8443,21 +8444,22 @@ public class PGraphicsOpenGL extends PGraphics { firstPointVertex = lastPointVertex = pointVertexCount = 0; firstPointIndex = lastPointIndex = pointIndexCount = 0; - fillIndexCache.clear(); + polyIndexCache.clear(); lineIndexCache.clear(); pointIndexCache.clear(); } void dipose() { - fillVertices = null; - fillColors = null; - fillNormals = null; - fillTexcoords = null; - fillAmbient = null; - fillSpecular = null; - fillEmissive = null; - fillShininess = null; - fillIndices = null; + polyVertices = null; + polyColors = null; + polyNormals = null; + polyTexcoords = null; + polyAmbient = null; + polySpecular = null; + polyEmissive = null; + polyShininess = null; + polyTypes = null; + polyIndices = null; lineVertices = null; lineColors = null; @@ -8470,67 +8472,68 @@ public class PGraphicsOpenGL extends PGraphics { pointIndices = null; } - void fillVertexCheck() { - if (fillVertexCount == fillVertices.length / 4) { - int newSize = fillVertexCount << 1; + void polyVertexCheck() { + if (polyVertexCount == polyVertices.length / 4) { + int newSize = polyVertexCount << 1; - expandFillVertices(newSize); - expandFillColors(newSize); - expandFillNormals(newSize); - expandFillTexcoords(newSize); - expandFillAmbient(newSize); - expandFillSpecular(newSize); - expandFillEmissive(newSize); - expandFillShininess(newSize); + expandPolyVertices(newSize); + expandPolyColors(newSize); + expandPolyNormals(newSize); + expandPolyTexcoords(newSize); + expandPolyAmbient(newSize); + expandPolySpecular(newSize); + expandPolyEmissive(newSize); + expandPolyShininess(newSize); + expandPolyTypes(newSize); } - firstFillVertex = fillVertexCount; - fillVertexCount++; - lastFillVertex = fillVertexCount - 1; + firstPolyVertex = polyVertexCount; + polyVertexCount++; + lastPolyVertex = polyVertexCount - 1; } - void fillVertexCheck(int count) { - int oldSize = fillVertices.length / 4; - if (fillVertexCount + count > oldSize) { - int newSize = expandArraySize(oldSize, fillVertexCount + count); + void polyVertexCheck(int count) { + int oldSize = polyVertices.length / 4; + if (polyVertexCount + count > oldSize) { + int newSize = expandArraySize(oldSize, polyVertexCount + count); - expandFillVertices(newSize); - expandFillColors(newSize); - expandFillNormals(newSize); - expandFillTexcoords(newSize); - expandFillAmbient(newSize); - expandFillSpecular(newSize); - expandFillEmissive(newSize); - expandFillShininess(newSize); + expandPolyVertices(newSize); + expandPolyColors(newSize); + expandPolyNormals(newSize); + expandPolyTexcoords(newSize); + expandPolyAmbient(newSize); + expandPolySpecular(newSize); + expandPolyEmissive(newSize); + expandPolyShininess(newSize); } - firstFillVertex = fillVertexCount; - fillVertexCount += count; - lastFillVertex = fillVertexCount - 1; + firstPolyVertex = polyVertexCount; + polyVertexCount += count; + lastPolyVertex = polyVertexCount - 1; } - void fillIndexCheck(int count) { - int oldSize = fillIndices.length; - if (fillIndexCount + count > oldSize) { - int newSize = expandArraySize(oldSize, fillIndexCount + count); + void polyIndexCheck(int count) { + int oldSize = polyIndices.length; + if (polyIndexCount + count > oldSize) { + int newSize = expandArraySize(oldSize, polyIndexCount + count); - expandFillIndices(newSize); + expandPolyIndices(newSize); } - firstFillIndex = fillIndexCount; - fillIndexCount += count; - lastFillIndex = fillIndexCount - 1; + firstPolyIndex = polyIndexCount; + polyIndexCount += count; + lastPolyIndex = polyIndexCount - 1; } - void fillIndexCheck() { - if (fillIndexCount == fillIndices.length) { - int newSize = fillIndexCount << 1; - expandFillIndices(newSize); + void polyIndexCheck() { + if (polyIndexCount == polyIndices.length) { + int newSize = polyIndexCount << 1; + expandPolyIndices(newSize); } - firstFillIndex = fillIndexCount; - fillIndexCount++; - lastFillIndex = fillIndexCount - 1; + firstPolyIndex = polyIndexCount; + polyIndexCount++; + lastPolyIndex = polyIndexCount - 1; } void lineVertexCheck(int count) { @@ -8594,17 +8597,17 @@ public class PGraphicsOpenGL extends PGraphics { // Query boolean isFull() { - return PGL.FLUSH_VERTEX_COUNT <= fillVertexCount || + return PGL.FLUSH_VERTEX_COUNT <= polyVertexCount || PGL.FLUSH_VERTEX_COUNT <= lineVertexCount || PGL.FLUSH_VERTEX_COUNT <= pointVertexCount; } - void getFillVertexMin(PVector v, int first, int last) { + void getPolyVertexMin(PVector v, int first, int last) { for (int i = first; i <= last; i++) { int index = 4 * i; - v.x = PApplet.min(v.x, fillVertices[index++]); - v.y = PApplet.min(v.y, fillVertices[index++]); - v.z = PApplet.min(v.z, fillVertices[index ]); + v.x = PApplet.min(v.x, polyVertices[index++]); + v.y = PApplet.min(v.y, polyVertices[index++]); + v.z = PApplet.min(v.z, polyVertices[index ]); } } @@ -8626,12 +8629,12 @@ public class PGraphicsOpenGL extends PGraphics { } } - void getFillVertexMax(PVector v, int first, int last) { + void getPolyVertexMax(PVector v, int first, int last) { for (int i = first; i <= last; i++) { int index = 4 * i; - v.x = PApplet.max(v.x, fillVertices[index++]); - v.y = PApplet.max(v.y, fillVertices[index++]); - v.z = PApplet.max(v.z, fillVertices[index ]); + v.x = PApplet.max(v.x, polyVertices[index++]); + v.y = PApplet.max(v.y, polyVertices[index++]); + v.z = PApplet.max(v.z, polyVertices[index ]); } } @@ -8653,12 +8656,12 @@ public class PGraphicsOpenGL extends PGraphics { } } - int getFillVertexSum(PVector v, int first, int last) { + int getPolyVertexSum(PVector v, int first, int last) { for (int i = first; i <= last; i++) { int index = 4 * i; - v.x += fillVertices[index++]; - v.y += fillVertices[index++]; - v.z += fillVertices[index ]; + v.x += polyVertices[index++]; + v.y += polyVertices[index++]; + v.z += polyVertices[index ]; } return last - first + 1; } @@ -8687,58 +8690,64 @@ public class PGraphicsOpenGL extends PGraphics { // // Expand arrays - void expandFillVertices(int n) { + void expandPolyVertices(int n) { float temp[] = new float[4 * n]; - PApplet.arrayCopy(fillVertices, 0, temp, 0, 4 * fillVertexCount); - fillVertices = temp; + PApplet.arrayCopy(polyVertices, 0, temp, 0, 4 * polyVertexCount); + polyVertices = temp; } - void expandFillColors(int n) { + void expandPolyColors(int n) { int temp[] = new int[n]; - PApplet.arrayCopy(fillColors, 0, temp, 0, fillVertexCount); - fillColors = temp; + PApplet.arrayCopy(polyColors, 0, temp, 0, polyVertexCount); + polyColors = temp; } - void expandFillNormals(int n) { + void expandPolyNormals(int n) { float temp[] = new float[3 * n]; - PApplet.arrayCopy(fillNormals, 0, temp, 0, 3 * fillVertexCount); - fillNormals = temp; + PApplet.arrayCopy(polyNormals, 0, temp, 0, 3 * polyVertexCount); + polyNormals = temp; } - void expandFillTexcoords(int n) { + void expandPolyTexcoords(int n) { float temp[] = new float[2 * n]; - PApplet.arrayCopy(fillTexcoords, 0, temp, 0, 2 * fillVertexCount); - fillTexcoords = temp; + PApplet.arrayCopy(polyTexcoords, 0, temp, 0, 2 * polyVertexCount); + polyTexcoords = temp; } - void expandFillAmbient(int n) { + void expandPolyAmbient(int n) { int temp[] = new int[n]; - PApplet.arrayCopy(fillAmbient, 0, temp, 0, fillVertexCount); - fillAmbient = temp; + PApplet.arrayCopy(polyAmbient, 0, temp, 0, polyVertexCount); + polyAmbient = temp; } - void expandFillSpecular(int n) { + void expandPolySpecular(int n) { int temp[] = new int[n]; - PApplet.arrayCopy(fillSpecular, 0, temp, 0, fillVertexCount); - fillSpecular = temp; + PApplet.arrayCopy(polySpecular, 0, temp, 0, polyVertexCount); + polySpecular = temp; } - void expandFillEmissive(int n) { + void expandPolyEmissive(int n) { int temp[] = new int[n]; - PApplet.arrayCopy(fillEmissive, 0, temp, 0, fillVertexCount); - fillEmissive = temp; + PApplet.arrayCopy(polyEmissive, 0, temp, 0, polyVertexCount); + polyEmissive = temp; } - void expandFillShininess(int n) { + void expandPolyShininess(int n) { float temp[] = new float[n]; - PApplet.arrayCopy(fillShininess, 0, temp, 0, fillVertexCount); - fillShininess = temp; + PApplet.arrayCopy(polyShininess, 0, temp, 0, polyVertexCount); + polyShininess = temp; + } + + void expandPolyTypes(int n) { + byte temp[] = new byte[n]; + PApplet.arrayCopy(polyTypes, 0, temp, 0, polyVertexCount); + polyTypes = temp; } - void expandFillIndices(int n) { + void expandPolyIndices(int n) { short temp[] = new short[n]; - PApplet.arrayCopy(fillIndices, 0, temp, 0, fillIndexCount); - fillIndices = temp; + PApplet.arrayCopy(polyIndices, 0, temp, 0, polyIndexCount); + polyIndices = temp; } void expandLineVertices(int n) { @@ -8794,19 +8803,20 @@ public class PGraphicsOpenGL extends PGraphics { // Trim arrays void trim() { - if (0 < fillVertexCount && fillVertexCount < fillVertices.length / 4) { - trimFillVertices(); - trimFillColors(); - trimFillNormals(); - trimFillTexcoords(); - trimFillAmbient(); - trimFillSpecular(); - trimFillEmissive(); - trimFillShininess(); + if (0 < polyVertexCount && polyVertexCount < polyVertices.length / 4) { + trimPolyVertices(); + trimPolyColors(); + trimPolyNormals(); + trimPolyTexcoords(); + trimPolyAmbient(); + trimPolySpecular(); + trimPolyEmissive(); + trimPolyShininess(); + trimPolyTypes(); } - if (0 < fillIndexCount && fillIndexCount < fillIndices.length) { - trimFillIndices(); + if (0 < polyIndexCount && polyIndexCount < polyIndices.length) { + trimPolyIndices(); } if (0 < lineVertexCount && lineVertexCount < lineVertices.length / 4) { @@ -8830,58 +8840,64 @@ public class PGraphicsOpenGL extends PGraphics { } } - void trimFillVertices() { - float temp[] = new float[4 * fillVertexCount]; - PApplet.arrayCopy(fillVertices, 0, temp, 0, 4 * fillVertexCount); - fillVertices = temp; + void trimPolyVertices() { + float temp[] = new float[4 * polyVertexCount]; + PApplet.arrayCopy(polyVertices, 0, temp, 0, 4 * polyVertexCount); + polyVertices = temp; } - void trimFillColors() { - int temp[] = new int[fillVertexCount]; - PApplet.arrayCopy(fillColors, 0, temp, 0, fillVertexCount); - fillColors = temp; + void trimPolyColors() { + int temp[] = new int[polyVertexCount]; + PApplet.arrayCopy(polyColors, 0, temp, 0, polyVertexCount); + polyColors = temp; } - void trimFillNormals() { - float temp[] = new float[3 * fillVertexCount]; - PApplet.arrayCopy(fillNormals, 0, temp, 0, 3 * fillVertexCount); - fillNormals = temp; + void trimPolyNormals() { + float temp[] = new float[3 * polyVertexCount]; + PApplet.arrayCopy(polyNormals, 0, temp, 0, 3 * polyVertexCount); + polyNormals = temp; } - void trimFillTexcoords() { - float temp[] = new float[2 * fillVertexCount]; - PApplet.arrayCopy(fillTexcoords, 0, temp, 0, 2 * fillVertexCount); - fillTexcoords = temp; + void trimPolyTexcoords() { + float temp[] = new float[2 * polyVertexCount]; + PApplet.arrayCopy(polyTexcoords, 0, temp, 0, 2 * polyVertexCount); + polyTexcoords = temp; } - void trimFillAmbient() { - int temp[] = new int[fillVertexCount]; - PApplet.arrayCopy(fillAmbient, 0, temp, 0, fillVertexCount); - fillAmbient = temp; + void trimPolyAmbient() { + int temp[] = new int[polyVertexCount]; + PApplet.arrayCopy(polyAmbient, 0, temp, 0, polyVertexCount); + polyAmbient = temp; } - void trimFillSpecular() { - int temp[] = new int[fillVertexCount]; - PApplet.arrayCopy(fillSpecular, 0, temp, 0, fillVertexCount); - fillSpecular = temp; + void trimPolySpecular() { + int temp[] = new int[polyVertexCount]; + PApplet.arrayCopy(polySpecular, 0, temp, 0, polyVertexCount); + polySpecular = temp; } - void trimFillEmissive() { - int temp[] = new int[fillVertexCount]; - PApplet.arrayCopy(fillEmissive, 0, temp, 0, fillVertexCount); - fillEmissive = temp; + void trimPolyEmissive() { + int temp[] = new int[polyVertexCount]; + PApplet.arrayCopy(polyEmissive, 0, temp, 0, polyVertexCount); + polyEmissive = temp; } - void trimFillShininess() { - float temp[] = new float[fillVertexCount]; - PApplet.arrayCopy(fillShininess, 0, temp, 0, fillVertexCount); - fillShininess = temp; + void trimPolyShininess() { + float temp[] = new float[polyVertexCount]; + PApplet.arrayCopy(polyShininess, 0, temp, 0, polyVertexCount); + polyShininess = temp; + } + + void trimPolyTypes() { + byte temp[] = new byte[polyVertexCount]; + PApplet.arrayCopy(polyTypes, 0, temp, 0, polyVertexCount); + polyTypes = temp; } - void trimFillIndices() { - short temp[] = new short[fillIndexCount]; - PApplet.arrayCopy(fillIndices, 0, temp, 0, fillIndexCount); - fillIndices = temp; + void trimPolyIndices() { + short temp[] = new short[polyIndexCount]; + PApplet.arrayCopy(polyIndices, 0, temp, 0, polyIndexCount); + polyIndices = temp; } void trimLineVertices() { @@ -8936,9 +8952,9 @@ public class PGraphicsOpenGL extends PGraphics { // // Aggregation methods - void incFillIndices(int first, int last, int inc) { + void incPolyIndices(int first, int last, int inc) { for (int i = first; i <= last; i++) { - fillIndices[i] += inc; + polyIndices[i] += inc; } } @@ -8958,23 +8974,23 @@ public class PGraphicsOpenGL extends PGraphics { // // Normal calculation - void calcFillNormal(int i0, int i1, int i2) { + void calcPolyNormal(int i0, int i1, int i2) { int index; index = 4 * i0; - float x0 = fillVertices[index++]; - float y0 = fillVertices[index++]; - float z0 = fillVertices[index ]; + float x0 = polyVertices[index++]; + float y0 = polyVertices[index++]; + float z0 = polyVertices[index ]; index = 4 * i1; - float x1 = fillVertices[index++]; - float y1 = fillVertices[index++]; - float z1 = fillVertices[index ]; + float x1 = polyVertices[index++]; + float y1 = polyVertices[index++]; + float z1 = polyVertices[index ]; index = 4 * i2; - float x2 = fillVertices[index++]; - float y2 = fillVertices[index++]; - float z2 = fillVertices[index ]; + float x2 = polyVertices[index++]; + float y2 = polyVertices[index++]; + float z2 = polyVertices[index ]; float v12x = x2 - x1; float v12y = y2 - y1; @@ -8993,19 +9009,19 @@ public class PGraphicsOpenGL extends PGraphics { nz /= d; index = 3 * i0; - fillNormals[index++] = nx; - fillNormals[index++] = ny; - fillNormals[index ] = nz; + polyNormals[index++] = nx; + polyNormals[index++] = ny; + polyNormals[index ] = nz; index = 3 * i1; - fillNormals[index++] = nx; - fillNormals[index++] = ny; - fillNormals[index ] = nz; + polyNormals[index++] = nx; + polyNormals[index++] = ny; + polyNormals[index ] = nz; index = 3 * i2; - fillNormals[index++] = nx; - fillNormals[index++] = ny; - fillNormals[index ] = nz; + polyNormals[index++] = nx; + polyNormals[index++] = ny; + polyNormals[index ] = nz; } // ----------------------------------------------------------------- @@ -9016,32 +9032,31 @@ public class PGraphicsOpenGL extends PGraphics { void setPointVertex(int tessIdx, InGeometry in, int inIdx) { int index; - index = 4 * inIdx; + index = 3 * inIdx; float x = in.vertices[index++]; float y = in.vertices[index++]; - float z = in.vertices[index++]; - float w = in.vertices[index ]; + float z = in.vertices[index ]; if (renderMode == IMMEDIATE && flushMode == FLUSH_WHEN_FULL && !hints[DISABLE_TRANSFORM_CACHE]) { PMatrix3D mm = modelview; index = 4 * tessIdx; - pointVertices[index++] = x * mm.m00 + y * mm.m01 + z * mm.m02 + w * mm.m03; - pointVertices[index++] = x * mm.m10 + y * mm.m11 + z * mm.m12 + w * mm.m13; - pointVertices[index++] = x * mm.m20 + y * mm.m21 + z * mm.m22 + w * mm.m23; - pointVertices[index ] = x * mm.m30 + y * mm.m31 + z * mm.m32 + w * mm.m33; + pointVertices[index++] = x * mm.m00 + y * mm.m01 + z * mm.m02 + mm.m03; + pointVertices[index++] = x * mm.m10 + y * mm.m11 + z * mm.m12 + mm.m13; + pointVertices[index++] = x * mm.m20 + y * mm.m21 + z * mm.m22 + mm.m23; + pointVertices[index ] = x * mm.m30 + y * mm.m31 + z * mm.m32 + mm.m33; } else { index = 4 * tessIdx; pointVertices[index++] = x; pointVertices[index++] = y; pointVertices[index++] = z; - pointVertices[index ] = w; + pointVertices[index ] = 1; } pointColors[tessIdx] = in.scolors[inIdx]; if (renderMode == RETAINED) { - in.tessMap.addPointIndex(inIdx, tessIdx); +// in.tessMap.addPointIndex(inIdx, tessIdx); } } @@ -9053,11 +9068,10 @@ public class PGraphicsOpenGL extends PGraphics { void setLineVertex(int tessIdx, InGeometry in, int inIdx0, int inIdx1, int rgba, float weight) { int index; - index = 4 * inIdx0; + index = 3 * inIdx0; float x0 = in.vertices[index++]; float y0 = in.vertices[index++]; - float z0 = in.vertices[index++]; - float w0 = in.vertices[index ]; + float z0 = in.vertices[index ]; index = 4 * inIdx1; float x1 = in.vertices[index++]; @@ -9068,10 +9082,10 @@ public class PGraphicsOpenGL extends PGraphics { PMatrix3D mm = modelview; index = 4 * tessIdx; - lineVertices[index++] = x0 * mm.m00 + y0 * mm.m01 + z0 * mm.m02 + w0 * mm.m03; - lineVertices[index++] = x0 * mm.m10 + y0 * mm.m11 + z0 * mm.m12 + w0 * mm.m13; - lineVertices[index++] = x0 * mm.m20 + y0 * mm.m21 + z0 * mm.m22 + w0 * mm.m23; - lineVertices[index ] = x0 * mm.m30 + y0 * mm.m31 + z0 * mm.m32 + w0 * mm.m33; + lineVertices[index++] = x0 * mm.m00 + y0 * mm.m01 + z0 * mm.m02 + mm.m03; + lineVertices[index++] = x0 * mm.m10 + y0 * mm.m11 + z0 * mm.m12 + mm.m13; + lineVertices[index++] = x0 * mm.m20 + y0 * mm.m21 + z0 * mm.m22 + mm.m23; + lineVertices[index ] = x0 * mm.m30 + y0 * mm.m31 + z0 * mm.m32 + mm.m33; index = 4 * tessIdx; lineDirWidths[index++] = x1 * mm.m00 + y1 * mm.m01 + z1 * mm.m02 + mm.m03; @@ -9082,7 +9096,7 @@ public class PGraphicsOpenGL extends PGraphics { lineVertices[index++] = x0; lineVertices[index++] = y0; lineVertices[index++] = z0; - lineVertices[index ] = w0; + lineVertices[index ] = 1; index = 4 * tessIdx; lineDirWidths[index++] = x1; @@ -9094,19 +9108,19 @@ public class PGraphicsOpenGL extends PGraphics { lineDirWidths[4 * tessIdx + 3] = weight; if (renderMode == RETAINED) { - in.tessMap.addLineIndex0(inIdx0, tessIdx); - in.tessMap.addLineIndex1(inIdx1, tessIdx); +// in.tessMap.addLineIndex0(inIdx0, tessIdx); +// in.tessMap.addLineIndex1(inIdx1, tessIdx); } } // ----------------------------------------------------------------- // - // Add fill geometry + // Add poly geometry - void setFillVertex(int tessIdx, float x, float y, float z, float w, + void setPolyVertex(int tessIdx, float x, float y, float z, int rgba, InGeometry in, int[] vertices) { - setFillVertex(tessIdx, x, y, z, w, + setPolyVertex(tessIdx, x, y, z, rgba, 0, 0, 1, 0, 0, @@ -9114,7 +9128,7 @@ public class PGraphicsOpenGL extends PGraphics { in, vertices); } - void setFillVertex(int tessIdx, float x, float y, float z, float w, + void setPolyVertex(int tessIdx, float x, float y, float z, int rgba, float nx, float ny, float nz, float u, float v, @@ -9127,38 +9141,38 @@ public class PGraphicsOpenGL extends PGraphics { PMatrix3D nm = modelviewInv; index = 4 * tessIdx; - fillVertices[index++] = x * mm.m00 + y * mm.m01 + z * mm.m02 + w * mm.m03; - fillVertices[index++] = x * mm.m10 + y * mm.m11 + z * mm.m12 + w * mm.m13; - fillVertices[index++] = x * mm.m20 + y * mm.m21 + z * mm.m22 + w * mm.m23; - fillVertices[index ] = x * mm.m30 + y * mm.m31 + z * mm.m32 + w * mm.m33; + polyVertices[index++] = x * mm.m00 + y * mm.m01 + z * mm.m02 + mm.m03; + polyVertices[index++] = x * mm.m10 + y * mm.m11 + z * mm.m12 + mm.m13; + polyVertices[index++] = x * mm.m20 + y * mm.m21 + z * mm.m22 + mm.m23; + polyVertices[index ] = x * mm.m30 + y * mm.m31 + z * mm.m32 + mm.m33; index = 3 * tessIdx; - fillNormals[index++] = nx * nm.m00 + ny * nm.m10 + nz * nm.m20; - fillNormals[index++] = nx * nm.m01 + ny * nm.m11 + nz * nm.m21; - fillNormals[index ] = nx * nm.m02 + ny * nm.m12 + nz * nm.m22; + polyNormals[index++] = nx * nm.m00 + ny * nm.m10 + nz * nm.m20; + polyNormals[index++] = nx * nm.m01 + ny * nm.m11 + nz * nm.m21; + polyNormals[index ] = nx * nm.m02 + ny * nm.m12 + nz * nm.m22; } else { index = 4 * tessIdx; - fillVertices[index++] = x; - fillVertices[index++] = y; - fillVertices[index++] = z; - fillVertices[index ] = w; + polyVertices[index++] = x; + polyVertices[index++] = y; + polyVertices[index++] = z; + polyVertices[index ] = 1; index = 3 * tessIdx; - fillNormals[index++] = nx; - fillNormals[index++] = ny; - fillNormals[index ] = nz; + polyNormals[index++] = nx; + polyNormals[index++] = ny; + polyNormals[index ] = nz; } - fillColors[tessIdx] = rgba; + polyColors[tessIdx] = rgba; index = 2 * tessIdx; - fillTexcoords[index++] = u; - fillTexcoords[index ] = v; + polyTexcoords[index++] = u; + polyTexcoords[index ] = v; - fillAmbient[tessIdx] = am; - fillSpecular[tessIdx] = sp; - fillEmissive[tessIdx] = em; - fillShininess[tessIdx] = shine; + polyAmbient[tessIdx] = am; + polySpecular[tessIdx] = sp; + polyEmissive[tessIdx] = em; + polyShininess[tessIdx] = shine; // NEW TESSMAP API // if (renderMode == RETAINED) { @@ -9168,58 +9182,58 @@ public class PGraphicsOpenGL extends PGraphics { if (renderMode == RETAINED && vertices != null) { int len = vertices.length; for (int i = 0; i < len; i++) { - in.tessMap.addFillIndex(vertices[i], tessIdx); +// in.tessMap.addFillIndex(vertices[i], tessIdx); } } } - void addFillVertex(float x, float y, float z, float w, + void addPolyVertex(float x, float y, float z, int rgba, float nx, float ny, float nz, float u, float v, int am, int sp, int em, float shine, InGeometry in, int[] vertices, float[] weights) { - fillVertexCheck(); + polyVertexCheck(); int index; - int count = fillVertexCount - 1; + int count = polyVertexCount - 1; if (renderMode == IMMEDIATE && flushMode == FLUSH_WHEN_FULL && !hints[DISABLE_TRANSFORM_CACHE]) { PMatrix3D mm = modelview; PMatrix3D nm = modelviewInv; index = 4 * count; - fillVertices[index++] = x * mm.m00 + y * mm.m01 + z * mm.m02 + w * mm.m03; - fillVertices[index++] = x * mm.m10 + y * mm.m11 + z * mm.m12 + w * mm.m13; - fillVertices[index++] = x * mm.m20 + y * mm.m21 + z * mm.m22 + w * mm.m23; - fillVertices[index ] = x * mm.m30 + y * mm.m31 + z * mm.m32 + w * mm.m33; + polyVertices[index++] = x * mm.m00 + y * mm.m01 + z * mm.m02 + mm.m03; + polyVertices[index++] = x * mm.m10 + y * mm.m11 + z * mm.m12 + mm.m13; + polyVertices[index++] = x * mm.m20 + y * mm.m21 + z * mm.m22 + mm.m23; + polyVertices[index ] = x * mm.m30 + y * mm.m31 + z * mm.m32 + mm.m33; index = 3 * count; - fillNormals[index++] = nx * nm.m00 + ny * nm.m10 + nz * nm.m20; - fillNormals[index++] = nx * nm.m01 + ny * nm.m11 + nz * nm.m21; - fillNormals[index ] = nx * nm.m02 + ny * nm.m12 + nz * nm.m22; + polyNormals[index++] = nx * nm.m00 + ny * nm.m10 + nz * nm.m20; + polyNormals[index++] = nx * nm.m01 + ny * nm.m11 + nz * nm.m21; + polyNormals[index ] = nx * nm.m02 + ny * nm.m12 + nz * nm.m22; } else { index = 4 * count; - fillVertices[index++] = x; - fillVertices[index++] = y; - fillVertices[index++] = z; - fillVertices[index ] = w; + polyVertices[index++] = x; + polyVertices[index++] = y; + polyVertices[index++] = z; + polyVertices[index ] = 1; index = 3 * count; - fillNormals[index++] = nx; - fillNormals[index++] = ny; - fillNormals[index ] = nz; + polyNormals[index++] = nx; + polyNormals[index++] = ny; + polyNormals[index ] = nz; } - fillColors[count] = rgba; + polyColors[count] = rgba; index = 2 * count; - fillTexcoords[index++] = u; - fillTexcoords[index ] = v; + polyTexcoords[index++] = u; + polyTexcoords[index ] = v; - fillAmbient[count] = am; - fillSpecular[count] = sp; - fillEmissive[count] = em; - fillShininess[count] = shine; + polyAmbient[count] = am; + polySpecular[count] = sp; + polyEmissive[count] = em; + polyShininess[count] = shine; // NEW TESSMAP API // if (renderMode == RETAINED) { @@ -9229,24 +9243,24 @@ public class PGraphicsOpenGL extends PGraphics { if (renderMode == RETAINED && vertices != null && weights != null) { int len = vertices.length; for (int i = 0; i < len; i++) { - in.tessMap.addFillIndex(vertices[i], count, weights[i]); +// in.tessMap.addFillIndex(vertices[i], count, weights[i]); } } } - void addFillVertices(InGeometry in) { - addFillVertices(in, in.firstVertex, in.lastVertex); + void addPolyVertices(InGeometry in) { + addPolyVertices(in, in.firstVertex, in.lastVertex); } - void addFillVertex(InGeometry in, int i) { - addFillVertices(in, i, i); + void addPolyVertex(InGeometry in, int i) { + addPolyVertices(in, i, i); } - void addFillVertices(InGeometry in, int i0, int i1) { + void addPolyVertices(InGeometry in, int i0, int i1) { int index; int nvert = i1 - i0 + 1; - fillVertexCheck(nvert); + polyVertexCheck(nvert); if (renderMode == IMMEDIATE && flushMode == FLUSH_WHEN_FULL && !hints[DISABLE_TRANSFORM_CACHE]) { PMatrix3D mm = modelview; @@ -9254,13 +9268,12 @@ public class PGraphicsOpenGL extends PGraphics { for (int i = 0; i < nvert; i++) { int inIdx = i0 + i; - int tessIdx = firstFillVertex + i; + int tessIdx = firstPolyVertex + i; - index = 4 * inIdx; + index = 3 * inIdx; float x = in.vertices[index++]; float y = in.vertices[index++]; - float z = in.vertices[index++]; - float w = in.vertices[index ]; + float z = in.vertices[index ]; index = 3 * inIdx; float nx = in.normals[index++]; @@ -9268,15 +9281,15 @@ public class PGraphicsOpenGL extends PGraphics { float nz = in.normals[index ]; index = 4 * tessIdx; - fillVertices[index++] = x * mm.m00 + y * mm.m01 + z * mm.m02 + w * mm.m03; - fillVertices[index++] = x * mm.m10 + y * mm.m11 + z * mm.m12 + w * mm.m13; - fillVertices[index++] = x * mm.m20 + y * mm.m21 + z * mm.m22 + w * mm.m23; - fillVertices[index ] = x * mm.m30 + y * mm.m31 + z * mm.m32 + w * mm.m33; + polyVertices[index++] = x * mm.m00 + y * mm.m01 + z * mm.m02 + mm.m03; + polyVertices[index++] = x * mm.m10 + y * mm.m11 + z * mm.m12 + mm.m13; + polyVertices[index++] = x * mm.m20 + y * mm.m21 + z * mm.m22 + mm.m23; + polyVertices[index ] = x * mm.m30 + y * mm.m31 + z * mm.m32 + mm.m33; index = 3 * tessIdx; - fillNormals[index++] = nx * nm.m00 + ny * nm.m10 + nz * nm.m20; - fillNormals[index++] = nx * nm.m01 + ny * nm.m11 + nz * nm.m21; - fillNormals[index ] = nx * nm.m02 + ny * nm.m12 + nz * nm.m22; + polyNormals[index++] = nx * nm.m00 + ny * nm.m10 + nz * nm.m20; + polyNormals[index++] = nx * nm.m01 + ny * nm.m11 + nz * nm.m21; + polyNormals[index ] = nx * nm.m02 + ny * nm.m12 + nz * nm.m22; } } else { if (nvert <= PGL.MIN_ARRAYCOPY_SIZE) { @@ -9284,13 +9297,12 @@ public class PGraphicsOpenGL extends PGraphics { // few vertices... for (int i = 0; i < nvert; i++) { int inIdx = i0 + i; - int tessIdx = firstFillVertex + i; + int tessIdx = firstPolyVertex + i; - index = 4 * inIdx; + index = 3 * inIdx; float x = in.vertices[index++]; float y = in.vertices[index++]; - float z = in.vertices[index++]; - float w = in.vertices[index ]; + float z = in.vertices[index ]; index = 3 * inIdx; float nx = in.normals[index++]; @@ -9298,49 +9310,54 @@ public class PGraphicsOpenGL extends PGraphics { float nz = in.normals[index ]; index = 4 * tessIdx; - fillVertices[index++] = x; - fillVertices[index++] = y; - fillVertices[index++] = z; - fillVertices[index ] = w; + polyVertices[index++] = x; + polyVertices[index++] = y; + polyVertices[index++] = z; + polyVertices[index ] = 1; index = 3 * tessIdx; - fillNormals[index++] = nx; - fillNormals[index++] = ny; - fillNormals[index ] = nz; + polyNormals[index++] = nx; + polyNormals[index++] = ny; + polyNormals[index ] = nz; } } else { - PApplet.arrayCopy(in.vertices, 4 * i0, fillVertices, 4 * firstFillVertex, 4 * nvert); - PApplet.arrayCopy(in.normals, 3 * i0, fillNormals, 3 * firstFillVertex, 3 * nvert); + for (int i = 0; i < nvert; i++) { + int inIdx = i0 + i; + int tessIdx = firstPolyVertex + i; + PApplet.arrayCopy(in.vertices, 3 * inIdx, polyVertices, 4 * tessIdx, 3); + polyVertices[4 * tessIdx + 3] = 1; + } + PApplet.arrayCopy(in.normals, 3 * i0, polyNormals, 3 * firstPolyVertex, 3 * nvert); } } if (nvert <= PGL.MIN_ARRAYCOPY_SIZE) { for (int i = 0; i < nvert; i++) { int inIdx = i0 + i; - int tessIdx = firstFillVertex + i; + int tessIdx = firstPolyVertex + i; index = 2 * inIdx; float u = in.texcoords[index++]; float v = in.texcoords[index ]; - fillColors[tessIdx] = in.colors[inIdx]; + polyColors[tessIdx] = in.colors[inIdx]; index = 2 * tessIdx; - fillTexcoords[index++] = u; - fillTexcoords[index ] = v; + polyTexcoords[index++] = u; + polyTexcoords[index ] = v; - fillAmbient[tessIdx] = in.ambient[inIdx]; - fillSpecular[tessIdx] = in.specular[inIdx]; - fillEmissive[tessIdx] = in.emissive[inIdx]; - fillShininess[tessIdx] = in.shininess[inIdx]; + polyAmbient[tessIdx] = in.ambient[inIdx]; + polySpecular[tessIdx] = in.specular[inIdx]; + polyEmissive[tessIdx] = in.emissive[inIdx]; + polyShininess[tessIdx] = in.shininess[inIdx]; } } else { - PApplet.arrayCopy(in.colors, i0, fillColors, firstFillVertex, nvert); - PApplet.arrayCopy(in.texcoords, 2 * i0, fillTexcoords, 2 * firstFillVertex, 2 * nvert); - PApplet.arrayCopy(in.ambient, i0, fillAmbient, firstFillVertex, nvert); - PApplet.arrayCopy(in.specular, i0, fillSpecular, firstFillVertex, nvert); - PApplet.arrayCopy(in.emissive, i0, fillEmissive, firstFillVertex, nvert); - PApplet.arrayCopy(in.shininess, i0, fillShininess, firstFillVertex, nvert); + PApplet.arrayCopy(in.colors, i0, polyColors, firstPolyVertex, nvert); + PApplet.arrayCopy(in.texcoords, 2 * i0, polyTexcoords, 2 * firstPolyVertex, 2 * nvert); + PApplet.arrayCopy(in.ambient, i0, polyAmbient, firstPolyVertex, nvert); + PApplet.arrayCopy(in.specular, i0, polySpecular, firstPolyVertex, nvert); + PApplet.arrayCopy(in.emissive, i0, polyEmissive, firstPolyVertex, nvert); + PApplet.arrayCopy(in.shininess, i0, polyShininess, firstPolyVertex, nvert); } // if (renderMode == RETAINED) { @@ -9349,9 +9366,9 @@ public class PGraphicsOpenGL extends PGraphics { if (renderMode == RETAINED) { for (int i = 0; i < nvert; i++) { - int inIdx = i0 + i; - int tessIdx = firstFillVertex + i; - in.tessMap.addFillIndex(inIdx, tessIdx); +// int inIdx = i0 + i; +// int tessIdx = firstPolyVertex + i; +// in.tessMap.addFillIndex(inIdx, tessIdx); } } } @@ -9360,11 +9377,11 @@ public class PGraphicsOpenGL extends PGraphics { // // Matrix transformations - void applyMatrixOnFillGeometry(PMatrix tr, int first, int last) { + void applyMatrixOnPolyGeometry(PMatrix tr, int first, int last) { if (tr instanceof PMatrix2D) { - applyMatrixOnFillGeometry((PMatrix2D) tr, first, last); + applyMatrixOnPolyGeometry((PMatrix2D) tr, first, last); } else if (tr instanceof PMatrix3D) { - applyMatrixOnFillGeometry((PMatrix3D) tr, first, last); + applyMatrixOnPolyGeometry((PMatrix3D) tr, first, last); } } @@ -9384,26 +9401,26 @@ public class PGraphicsOpenGL extends PGraphics { } } - void applyMatrixOnFillGeometry(PMatrix2D tr, int first, int last) { + void applyMatrixOnPolyGeometry(PMatrix2D tr, int first, int last) { if (first < last) { int index; for (int i = first; i <= last; i++) { index = 4 * i; - float x = fillVertices[index++]; - float y = fillVertices[index ]; + float x = polyVertices[index++]; + float y = polyVertices[index ]; index = 3 * i; - float nx = fillNormals[index++]; - float ny = fillNormals[index ]; + float nx = polyNormals[index++]; + float ny = polyNormals[index ]; index = 4 * i; - fillVertices[index++] = x * tr.m00 + y * tr.m01 + tr.m02; - fillVertices[index ] = x * tr.m10 + y * tr.m11 + tr.m12; + polyVertices[index++] = x * tr.m00 + y * tr.m01 + tr.m02; + polyVertices[index ] = x * tr.m10 + y * tr.m11 + tr.m12; index = 3 * i; - fillNormals[index++] = nx * tr.m00 + ny * tr.m01; - fillNormals[index ] = nx * tr.m10 + ny * tr.m11; + polyNormals[index++] = nx * tr.m00 + ny * tr.m01; + polyNormals[index ] = nx * tr.m10 + ny * tr.m11; } } } @@ -9448,32 +9465,32 @@ public class PGraphicsOpenGL extends PGraphics { } } - void applyMatrixOnFillGeometry(PMatrix3D tr, int first, int last) { + void applyMatrixOnPolyGeometry(PMatrix3D tr, int first, int last) { if (first < last) { int index; for (int i = first; i <= last; i++) { index = 4 * i; - float x = fillVertices[index++]; - float y = fillVertices[index++]; - float z = fillVertices[index++]; - float w = fillVertices[index ]; + float x = polyVertices[index++]; + float y = polyVertices[index++]; + float z = polyVertices[index++]; + float w = polyVertices[index ]; index = 3 * i; - float nx = fillNormals[index++]; - float ny = fillNormals[index++]; - float nz = fillNormals[index ]; + float nx = polyNormals[index++]; + float ny = polyNormals[index++]; + float nz = polyNormals[index ]; index = 4 * i; - fillVertices[index++] = x * tr.m00 + y * tr.m01 + z * tr.m02 + w * tr.m03; - fillVertices[index++] = x * tr.m10 + y * tr.m11 + z * tr.m12 + w * tr.m13; - fillVertices[index++] = x * tr.m20 + y * tr.m21 + z * tr.m22 + w * tr.m23; - fillVertices[index ] = x * tr.m30 + y * tr.m31 + z * tr.m32 + w * tr.m33; + polyVertices[index++] = x * tr.m00 + y * tr.m01 + z * tr.m02 + w * tr.m03; + polyVertices[index++] = x * tr.m10 + y * tr.m11 + z * tr.m12 + w * tr.m13; + polyVertices[index++] = x * tr.m20 + y * tr.m21 + z * tr.m22 + w * tr.m23; + polyVertices[index ] = x * tr.m30 + y * tr.m31 + z * tr.m32 + w * tr.m33; index = 3 * i; - fillNormals[index++] = nx * tr.m00 + ny * tr.m01 + nz * tr.m02; - fillNormals[index++] = nx * tr.m10 + ny * tr.m11 + nz * tr.m12; - fillNormals[index ] = nx * tr.m20 + ny * tr.m21 + nz * tr.m22; + polyNormals[index++] = nx * tr.m00 + ny * tr.m01 + nz * tr.m02; + polyNormals[index++] = nx * tr.m10 + ny * tr.m11 + nz * tr.m12; + polyNormals[index ] = nx * tr.m20 + ny * tr.m21 + nz * tr.m22; } } } @@ -9552,12 +9569,12 @@ public class PGraphicsOpenGL extends PGraphics { int[] rawIndices; int rawSize; + int firstPolyIndexCache; + int lastPolyIndexCache; + int firstLineIndexCache; + int lastLineIndexCache; int firstPointIndexCache; int lastPointIndexCache; - int firstLineIndexCache; - int lastLineIndexCache; - int firstFillIndexCache; - int lastFillIndexCache; Tessellator() { callback = new TessellatorCallback(); @@ -9567,13 +9584,13 @@ public class PGraphicsOpenGL extends PGraphics { void setInGeometry(InGeometry in) { this.in = in; - + + firstPolyIndexCache = -1; + lastPolyIndexCache = -1; + firstLineIndexCache = -1; + lastLineIndexCache = -1; firstPointIndexCache = -1; lastPointIndexCache = -1; - firstLineIndexCache = -1; - lastLineIndexCache = -1; - firstFillIndexCache = -1; - lastFillIndexCache = -1; } void setTessGeometry(TessGeometry tess) { @@ -9700,18 +9717,18 @@ public class PGraphicsOpenGL extends PGraphics { // in.addPointMapping(in.firstVertex, in.lastVertex, tess.firstPointVertex, nPtVert); // } } else { - // Point geometry is stored in the fill arrays, but is never textured + // Point geometry is stored in the poly arrays, but is never textured prevTexImage = newTexImage; newTexImage = null; - setFirstTexIndex(tess.fillIndexCount, tess.fillIndexCache.size - 1); + setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1); - tess.fillVertexCheck(nvertTot); - tess.fillIndexCheck(nindTot); - int vertIdx = tess.firstFillVertex; - int indIdx = tess.firstFillIndex; - IndexCache cache = tess.fillIndexCache; + tess.polyVertexCheck(nvertTot); + tess.polyIndexCheck(nindTot); + int vertIdx = tess.firstPolyVertex; + int indIdx = tess.firstPolyIndex; + IndexCache cache = tess.polyIndexCache; int index = in.renderMode == RETAINED ? cache.addNew() : cache.getLast(); - firstFillIndexCache = index; + firstPolyIndexCache = index; for (int i = in.firstVertex; i <= in.lastVertex; i++) { int count = cache.vertexCount[index]; if (PGL.MAX_VERTEX_INDEX1 <= count + nPtVert) { @@ -9720,21 +9737,20 @@ public class PGraphicsOpenGL extends PGraphics { count = 0; } - float x0 = in.vertices[4 * i + 0]; - float y0 = in.vertices[4 * i + 1]; - float w0 = in.vertices[4 * i + 3]; + float x0 = in.vertices[3 * i + 0]; + float y0 = in.vertices[3 * i + 1]; int rgba = in.scolors[i]; if (in.renderMode == RETAINED) { - in.tessMap.addFillIndex(i, -1); +// in.tessMap.addFillIndex(i, -1); } float val = 0; float inc = (float) SINCOS_LENGTH / perim; - tess.setFillVertex(vertIdx, x0, y0, 0, w0, rgba, in, null); + tess.setPolyVertex(vertIdx, x0, y0, 0, rgba, in, null); vertIdx++; for (int k = 0; k < perim; k++) { - tess.setFillVertex(vertIdx, x0 + 0.5f * cosLUT[(int) val] * strokeWeight, - y0 + 0.5f * sinLUT[(int) val] * strokeWeight, 0, w0, rgba, in, null); + tess.setPolyVertex(vertIdx, x0 + 0.5f * cosLUT[(int) val] * strokeWeight, + y0 + 0.5f * sinLUT[(int) val] * strokeWeight, 0, rgba, in, null); vertIdx++; val = (val + inc) % SINCOS_LENGTH; } @@ -9742,23 +9758,23 @@ public class PGraphicsOpenGL extends PGraphics { // Adding vert0 to take into account the triangles of all // the preceding points. for (int k = 1; k < nPtVert - 1; k++) { - tess.fillIndices[indIdx++] = (short) (count + 0); - tess.fillIndices[indIdx++] = (short) (count + k); - tess.fillIndices[indIdx++] = (short) (count + k + 1); + tess.polyIndices[indIdx++] = (short) (count + 0); + tess.polyIndices[indIdx++] = (short) (count + k); + tess.polyIndices[indIdx++] = (short) (count + k + 1); } // Final triangle between the last and first point: - tess.fillIndices[indIdx++] = (short) (count + 0); - tess.fillIndices[indIdx++] = (short) (count + 1); - tess.fillIndices[indIdx++] = (short) (count + nPtVert - 1); + tess.polyIndices[indIdx++] = (short) (count + 0); + tess.polyIndices[indIdx++] = (short) (count + 1); + tess.polyIndices[indIdx++] = (short) (count + nPtVert - 1); cache.incCounts(index, 3 * (nPtVert - 1), nPtVert); } - lastFillIndexCache = index; + lastPolyIndexCache = index; // NEW TESSMAP API // if (tess.renderMode == RETAINED) { // ???? // } - setLastTexIndex(tess.lastFillIndex, tess.fillIndexCache.size - 1); + setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1); } } } @@ -9835,18 +9851,18 @@ public class PGraphicsOpenGL extends PGraphics { // in.addPointMapping(in.firstVertex, in.lastVertex, tess.firstPointVertex, 5); // } } else { - // Point geometry is stored in the fill arrays, but is never textured + // Point geometry is stored in the poly arrays, but is never textured prevTexImage = newTexImage; newTexImage = null; - setFirstTexIndex(tess.fillIndexCount, tess.fillIndexCache.size - 1); + setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1); - tess.fillVertexCheck(nvertTot); - tess.fillIndexCheck(nindTot); - int vertIdx = tess.firstFillVertex; - int indIdx = tess.firstFillIndex; - IndexCache cache = tess.fillIndexCache; + tess.polyVertexCheck(nvertTot); + tess.polyIndexCheck(nindTot); + int vertIdx = tess.firstPolyVertex; + int indIdx = tess.firstPolyIndex; + IndexCache cache = tess.polyIndexCache; int index = in.renderMode == RETAINED ? cache.addNew() : cache.getLast(); - firstFillIndexCache = index; + firstPolyIndexCache = index; for (int i = in.firstVertex; i <= in.lastVertex; i++) { int nvert = 5; int count = cache.vertexCount[index]; @@ -9856,41 +9872,40 @@ public class PGraphicsOpenGL extends PGraphics { count = 0; } - float x0 = in.vertices[4 * i + 0]; - float y0 = in.vertices[4 * i + 1]; - float w0 = in.vertices[4 * i + 3]; + float x0 = in.vertices[3 * i + 0]; + float y0 = in.vertices[3 * i + 1]; int rgba = in.scolors[i]; if (in.renderMode == RETAINED) { - in.tessMap.addFillIndex(i, -1); +// in.tessMap.addFillIndex(i, -1); } - tess.setFillVertex(vertIdx, x0, y0, 0, w0, rgba, in, null); + tess.setPolyVertex(vertIdx, x0, y0, 0, rgba, in, null); vertIdx++; for (int k = 0; k < nvert - 1; k++) { - tess.setFillVertex(vertIdx, x0 + 0.5f * QUAD_POINT_SIGNS[k][0] * strokeWeight, - y0 + 0.5f * QUAD_POINT_SIGNS[k][1] * strokeWeight, 0, w0, rgba, in, null); + tess.setPolyVertex(vertIdx, x0 + 0.5f * QUAD_POINT_SIGNS[k][0] * strokeWeight, + y0 + 0.5f * QUAD_POINT_SIGNS[k][1] * strokeWeight, 0, rgba, in, null); vertIdx++; } for (int k = 1; k < nvert - 1; k++) { - tess.fillIndices[indIdx++] = (short) (count + 0); - tess.fillIndices[indIdx++] = (short) (count + k); - tess.fillIndices[indIdx++] = (short) (count + k + 1); + tess.polyIndices[indIdx++] = (short) (count + 0); + tess.polyIndices[indIdx++] = (short) (count + k); + tess.polyIndices[indIdx++] = (short) (count + k + 1); } // Final triangle between the last and first point: - tess.fillIndices[indIdx++] = (short) (count + 0); - tess.fillIndices[indIdx++] = (short) (count + 1); - tess.fillIndices[indIdx++] = (short) (count + nvert - 1); + tess.polyIndices[indIdx++] = (short) (count + 0); + tess.polyIndices[indIdx++] = (short) (count + 1); + tess.polyIndices[indIdx++] = (short) (count + nvert - 1); cache.incCounts(index, 12, 5); } - lastFillIndexCache = index; + lastPolyIndexCache = index; // NEW TESSMAP API // if (tess.renderMode == RETAINED) { // ????? // } - setLastTexIndex(tess.lastFillIndex, tess.fillIndexCache.size - 1); + setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1); } } } @@ -9928,23 +9943,23 @@ public class PGraphicsOpenGL extends PGraphics { // addLineMapping(in.firstVertex, in.lastVertex); // } } else { - // Line geometry is stored in the fill arrays, but is never textured + // Line geometry is stored in the poly arrays, but is never textured prevTexImage = newTexImage; newTexImage = null; - setFirstTexIndex(tess.fillIndexCount, tess.fillIndexCache.size - 1); + setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1); - // 2D renderer, the stroke geometry is stored in the fill array for accurate depth sorting + // 2D renderer, the stroke geometry is stored in the poly array for accurate depth sorting if (strokeWeight < PGL.MIN_CAPS_JOINS_WEIGHT) { // no caps, joins - tess.fillVertexCheck(nvert); - tess.fillIndexCheck(nind); - int index = in.renderMode == RETAINED ? tess.fillIndexCache.addNew() : tess.fillIndexCache.getLast(); - firstFillIndexCache = index; + tess.polyVertexCheck(nvert); + tess.polyIndexCheck(nind); + int index = in.renderMode == RETAINED ? tess.polyIndexCache.addNew() : tess.polyIndexCache.getLast(); + firstPolyIndexCache = index; for (int ln = 0; ln < lineCount; ln++) { int i0 = first + 2 * ln + 0; int i1 = first + 2 * ln + 1; index = addLine2D(i0, i1, index, false); } - lastFillIndexCache = index; + lastPolyIndexCache = index; // NEW TESSMAP API // if (tess.renderMode == RETAINED) { // ???? @@ -9954,19 +9969,19 @@ public class PGraphicsOpenGL extends PGraphics { for (int ln = 0; ln < lineCount; ln++) { int i0 = first + 2 * ln + 0; int i1 = first + 2 * ln + 1; - path.moveTo(in.vertices[4 * i0 + 0], in.vertices[4 * i0 + 1]); - path.lineTo(in.vertices[4 * i1 + 0], in.vertices[4 * i1 + 1]); + path.moveTo(in.vertices[3 * i0 + 0], in.vertices[3 * i0 + 1]); + path.lineTo(in.vertices[3 * i1 + 0], in.vertices[3 * i1 + 1]); if (tess.renderMode == RETAINED) { // The input vertices cannot the tessellated geometry - in.tessMap.addFillIndex(i0, -1); - in.tessMap.addFillIndex(i1, -1); +// in.tessMap.addFillIndex(i0, -1); +// in.tessMap.addFillIndex(i1, -1); } } tessellateLinePath(path, false); } } - setLastTexIndex(tess.lastFillIndex, tess.fillIndexCache.size - 1); + setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1); } } @@ -9997,21 +10012,21 @@ public class PGraphicsOpenGL extends PGraphics { } else { prevTexImage = newTexImage; newTexImage = null; - setFirstTexIndex(tess.fillIndexCount, tess.fillIndexCache.size - 1); + setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1); - // 2D renderer, the stroke geometry is stored in the fill array for accurate depth sorting + // 2D renderer, the stroke geometry is stored in the poly array for accurate depth sorting if (strokeWeight < PGL.MIN_CAPS_JOINS_WEIGHT) { // no caps, joins - tess.fillVertexCheck(nvert); - tess.fillIndexCheck(nind); - int index = in.renderMode == RETAINED ? tess.fillIndexCache.addNew() : tess.fillIndexCache.getLast(); - firstFillIndexCache = index; + tess.polyVertexCheck(nvert); + tess.polyIndexCheck(nind); + int index = in.renderMode == RETAINED ? tess.polyIndexCache.addNew() : tess.polyIndexCache.getLast(); + firstPolyIndexCache = index; int i0 = in.firstVertex; for (int ln = 0; ln < lineCount; ln++) { int i1 = in.firstVertex + ln + 1; index = addLine2D(i0, i1, index, false); i0 = i1; } - lastFillIndexCache = index; + lastPolyIndexCache = index; // NEW TESSMAP API // if (tess.renderMode == RETAINED) { // ????? @@ -10019,22 +10034,22 @@ public class PGraphicsOpenGL extends PGraphics { } else { // full stroking algorithm int first = in.firstVertex; LinePath path = new LinePath(LinePath.WIND_NON_ZERO); - path.moveTo(in.vertices[4 * first + 0], in.vertices[4 * first + 1]); + path.moveTo(in.vertices[3 * first + 0], in.vertices[3 * first + 1]); if (tess.renderMode == RETAINED) { - in.tessMap.addFillIndex(first, -1); +// in.tessMap.addFillIndex(first, -1); } for (int ln = 0; ln < lineCount; ln++) { int i1 = first + ln + 1; - path.lineTo(in.vertices[4 * i1 + 0], in.vertices[4 * i1 + 1]); + path.lineTo(in.vertices[3 * i1 + 0], in.vertices[3 * i1 + 1]); if (tess.renderMode == RETAINED) { - in.tessMap.addFillIndex(i1, -1); +// in.tessMap.addFillIndex(i1, -1); } } tessellateLinePath(path, false); } } - setLastTexIndex(tess.lastFillIndex, tess.fillIndexCache.size - 1); + setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1); } } @@ -10066,14 +10081,14 @@ public class PGraphicsOpenGL extends PGraphics { } else { prevTexImage = newTexImage; newTexImage = null; - setFirstTexIndex(tess.fillIndexCount, tess.fillIndexCache.size - 1); + setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1); - // 2D renderer, the stroke geometry is stored in the fill array for accurate depth sorting + // 2D renderer, the stroke geometry is stored in the poly array for accurate depth sorting if (strokeWeight < PGL.MIN_CAPS_JOINS_WEIGHT) { // no caps, joins - tess.fillVertexCheck(nvert); - tess.fillIndexCheck(nind); - int index = in.renderMode == RETAINED ? tess.fillIndexCache.addNew() : tess.fillIndexCache.getLast(); - firstFillIndexCache = index; + tess.polyVertexCheck(nvert); + tess.polyIndexCheck(nind); + int index = in.renderMode == RETAINED ? tess.polyIndexCache.addNew() : tess.polyIndexCache.getLast(); + firstPolyIndexCache = index; int i0 = in.firstVertex; for (int ln = 0; ln < lineCount - 1; ln++) { int i1 = in.firstVertex + ln + 1; @@ -10081,7 +10096,7 @@ public class PGraphicsOpenGL extends PGraphics { i0 = i1; } index = addLine2D(in.lastVertex, in.firstVertex, index, false); - lastFillIndexCache = index; + lastPolyIndexCache = index; // NEW TESSMAP API // if (tess.renderMode == RETAINED) { // ????? @@ -10089,15 +10104,15 @@ public class PGraphicsOpenGL extends PGraphics { } else { // full stroking algorithm int first = in.firstVertex; LinePath path = new LinePath(LinePath.WIND_NON_ZERO); - path.moveTo(in.vertices[4 * first + 0], in.vertices[4 * first + 1]); + path.moveTo(in.vertices[3 * first + 0], in.vertices[3 * first + 1]); if (tess.renderMode == RETAINED) { - in.tessMap.addFillIndex(first, -1); +// in.tessMap.addFillIndex(first, -1); } for (int ln = 0; ln < lineCount - 1; ln++) { int i1 = first + ln + 1; - path.lineTo(in.vertices[4 * i1 + 0], in.vertices[4 * i1 + 1]); + path.lineTo(in.vertices[3 * i1 + 0], in.vertices[3 * i1 + 1]); if (tess.renderMode == RETAINED) { - in.tessMap.addFillIndex(i1, -1); +// in.tessMap.addFillIndex(i1, -1); } } path.closePath(); @@ -10105,7 +10120,7 @@ public class PGraphicsOpenGL extends PGraphics { } } - setLastTexIndex(tess.lastFillIndex, tess.fillIndexCache.size - 1); + setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1); } } @@ -10131,19 +10146,19 @@ public class PGraphicsOpenGL extends PGraphics { } else { prevTexImage = newTexImage; newTexImage = null; - setFirstTexIndex(tess.fillIndexCount, tess.fillIndexCache.size - 1); + setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1); - // 2D renderer, the stroke geometry is stored in the fill array for accurate depth sorting + // 2D renderer, the stroke geometry is stored in the poly array for accurate depth sorting if (strokeWeight < PGL.MIN_CAPS_JOINS_WEIGHT) { // no caps, edges - tess.fillVertexCheck(nInVert); - tess.fillIndexCheck(nInInd); - int index = in.renderMode == RETAINED && !haveFill ? tess.fillIndexCache.addNew() : tess.fillIndexCache.getLast(); - firstFillIndexCache = index; + tess.polyVertexCheck(nInVert); + tess.polyIndexCheck(nInInd); + int index = in.renderMode == RETAINED && !haveFill ? tess.polyIndexCache.addNew() : tess.polyIndexCache.getLast(); + firstPolyIndexCache = index; for (int i = in.firstEdge; i <= in.lastEdge; i++) { int[] edge = in.edges[i]; index = addLine2D(edge[0], edge[1], index, true); } - lastFillIndexCache = index; + lastPolyIndexCache = index; // NEW TESSMAP API // if (tess.renderMode == RETAINED) { // ???? @@ -10156,31 +10171,31 @@ public class PGraphicsOpenGL extends PGraphics { int i1 = edge[1]; switch (edge[2]) { case EDGE_MIDDLE: - path.lineTo(in.vertices[4 * i1 + 0], in.vertices[4 * i1 + 1]); + path.lineTo(in.vertices[3 * i1 + 0], in.vertices[3 * i1 + 1]); break; case EDGE_START: - path.moveTo(in.vertices[4 * i0 + 0], in.vertices[4 * i0 + 1]); - path.lineTo(in.vertices[4 * i1 + 0], in.vertices[4 * i1 + 1]); + path.moveTo(in.vertices[3 * i0 + 0], in.vertices[3 * i0 + 1]); + path.lineTo(in.vertices[3 * i1 + 0], in.vertices[3 * i1 + 1]); break; case EDGE_STOP: - path.lineTo(in.vertices[4 * i1 + 0], in.vertices[4 * i1 + 1]); + path.lineTo(in.vertices[3 * i1 + 0], in.vertices[3 * i1 + 1]); path.closePath(); break; case EDGE_SINGLE: - path.moveTo(in.vertices[4 * i0 + 0], in.vertices[4 * i0 + 1]); - path.lineTo(in.vertices[4 * i1 + 0], in.vertices[4 * i1 + 1]); + path.moveTo(in.vertices[3 * i0 + 0], in.vertices[3 * i0 + 1]); + path.lineTo(in.vertices[3 * i1 + 0], in.vertices[3 * i1 + 1]); path.closePath(); break; } if (tess.renderMode == RETAINED) { - in.tessMap.addFillIndex(i0, -1); - in.tessMap.addFillIndex(i1, -1); +// in.tessMap.addFillIndex(i0, -1); +// in.tessMap.addFillIndex(i1, -1); } } tessellateLinePath(path, haveFill); } - setLastTexIndex(tess.lastFillIndex, tess.fillIndexCache.size - 1); + setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1); } } } @@ -10237,9 +10252,9 @@ public class PGraphicsOpenGL extends PGraphics { // Adding the data that defines a quad starting at vertex i0 and // ending at i1, in the case of pure 2D renderers (line geometry - // is added to the fill arrays). + // is added to the poly arrays). int addLine2D(int i0, int i1, int index, boolean constStroke) { - IndexCache cache = tess.fillIndexCache; + IndexCache cache = tess.polyIndexCache; int count = cache.vertexCount[index]; if (PGL.MAX_VERTEX_INDEX1 <= count + 4) { // We need to start a new index block for this line. @@ -10255,13 +10270,11 @@ public class PGraphicsOpenGL extends PGraphics { weight = constStroke ? strokeWeight : in.sweights[i0]; int[] verts = {i0, i1}; - float x0 = in.vertices[4 * i0 + 0]; - float y0 = in.vertices[4 * i0 + 1]; - float w0 = in.vertices[4 * i0 + 3]; + float x0 = in.vertices[3 * i0 + 0]; + float y0 = in.vertices[3 * i0 + 1]; - float x1 = in.vertices[4 * i1 + 0]; - float y1 = in.vertices[4 * i1 + 1]; - float w1 = in.vertices[4 * i1 + 3]; + float x1 = in.vertices[3 * i1 + 0]; + float y1 = in.vertices[3 * i1 + 1]; // Calculating direction and normal of the line. float dirx = x1 - x0; @@ -10270,27 +10283,27 @@ public class PGraphicsOpenGL extends PGraphics { float normx = -diry / llen; float normy = +dirx / llen; - tess.setFillVertex(vidx, x0 + normx * weight/2, y0 + normy * weight/2, 0, w0, color, in, verts); - tess.fillIndices[iidx++] = (short) (count + 0); + tess.setPolyVertex(vidx, x0 + normx * weight/2, y0 + normy * weight/2, 0, color, in, verts); + tess.polyIndices[iidx++] = (short) (count + 0); vidx++; - tess.setFillVertex(vidx, x0 - normx * weight/2, y0 - normy * weight/2, 0, w0, color, in, verts); - tess.fillIndices[iidx++] = (short) (count + 1); + tess.setPolyVertex(vidx, x0 - normx * weight/2, y0 - normy * weight/2, 0, color, in, verts); + tess.polyIndices[iidx++] = (short) (count + 1); color = constStroke ? strokeColor : in.scolors[i1]; weight = constStroke ? strokeWeight : in.sweights[i1]; vidx++; - tess.setFillVertex(vidx, x1 - normx * weight/2, y1 - normy * weight/2, 0, w1, color, in, verts); - tess.fillIndices[iidx++] = (short) (count + 2); + tess.setPolyVertex(vidx, x1 - normx * weight/2, y1 - normy * weight/2, 0, color, in, verts); + tess.polyIndices[iidx++] = (short) (count + 2); // Starting a new triangle re-using prev vertices. - tess.fillIndices[iidx++] = (short) (count + 2); - tess.fillIndices[iidx++] = (short) (count + 0); + tess.polyIndices[iidx++] = (short) (count + 2); + tess.polyIndices[iidx++] = (short) (count + 0); vidx++; - tess.setFillVertex(vidx, x1 + normx * weight/2, y1 + normy * weight/2, 0, w1, color, in, verts); - tess.fillIndices[iidx++] = (short) (count + 3); + tess.setPolyVertex(vidx, x1 + normx * weight/2, y1 + normy * weight/2, 0, color, in, verts); + tess.polyIndices[iidx++] = (short) (count + 3); // NEW TESSMAP API // if (tess.renderMode == RETAINED) { @@ -10304,10 +10317,10 @@ public class PGraphicsOpenGL extends PGraphics { // ----------------------------------------------------------------- // - // Fill primitives tessellation + // Polygon primitives tessellation void tessellateTriangles() { - setFirstTexIndex(tess.fillIndexCount, tess.fillIndexCache.size - 1); + setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1); int nInVert = in.lastVertex - in.firstVertex + 1; if (fill && 3 <= nInVert) { int nInInd = nInVert; @@ -10318,12 +10331,12 @@ public class PGraphicsOpenGL extends PGraphics { } partitionRawIndices(); } - setLastTexIndex(tess.lastFillIndex, tess.fillIndexCache.size - 1); + setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1); tessellateEdges(fill && 3 <= nInVert); } void tessellateTriangles(int[] indices) { - setFirstTexIndex(tess.fillIndexCount, tess.fillIndexCache.size - 1); + setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1); int nInVert = in.lastVertex - in.firstVertex + 1; if (fill && 3 <= nInVert) { int nInInd = indices.length; @@ -10331,12 +10344,12 @@ public class PGraphicsOpenGL extends PGraphics { PApplet.arrayCopy(indices, rawIndices, nInInd); partitionRawIndices(); } - setLastTexIndex(tess.lastFillIndex, tess.fillIndexCache.size - 1); + setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1); tessellateEdges(fill && 3 <= nInVert); } void tessellateTriangleFan() { - setFirstTexIndex(tess.fillIndexCount, tess.fillIndexCache.size - 1); + setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1); int nInVert = in.lastVertex - in.firstVertex + 1; if (fill && 3 <= nInVert) { int nInInd = 3 * (nInVert - 2); @@ -10349,12 +10362,12 @@ public class PGraphicsOpenGL extends PGraphics { } partitionRawIndices(); } - setLastTexIndex(tess.lastFillIndex, tess.fillIndexCache.size - 1); + setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1); tessellateEdges(fill && 3 <= nInVert); } void tessellateTriangleStrip() { - setFirstTexIndex(tess.fillIndexCount, tess.fillIndexCache.size - 1); + setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1); int nInVert = in.lastVertex - in.firstVertex + 1; if (fill && 3 <= nInVert) { int nInInd = 3 * (nInVert - 2); @@ -10372,12 +10385,12 @@ public class PGraphicsOpenGL extends PGraphics { } partitionRawIndices(); } - setLastTexIndex(tess.lastFillIndex, tess.fillIndexCache.size - 1); + setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1); tessellateEdges(fill && 3 <= nInVert); } void tessellateQuads() { - setFirstTexIndex(tess.fillIndexCount, tess.fillIndexCache.size - 1); + setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1); int nInVert = in.lastVertex - in.firstVertex + 1; if (fill && 4 <= nInVert) { int quadCount = nInVert / 4; @@ -10400,12 +10413,12 @@ public class PGraphicsOpenGL extends PGraphics { } partitionRawIndices(); } - setLastTexIndex(tess.lastFillIndex, tess.fillIndexCache.size - 1); + setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1); tessellateEdges(fill && 4 <= nInVert); } void tessellateQuadStrip() { - setFirstTexIndex(tess.fillIndexCount, tess.fillIndexCache.size - 1); + setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1); int nInVert = in.lastVertex - in.firstVertex + 1; if (fill && 4 <= nInVert) { int quadCount = nInVert / 2 - 1; @@ -10428,7 +10441,7 @@ public class PGraphicsOpenGL extends PGraphics { } partitionRawIndices(); } - setLastTexIndex(tess.lastFillIndex, tess.fillIndexCache.size - 1); + setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1); tessellateEdges(fill && 4 <= nInVert); } @@ -10443,20 +10456,20 @@ public class PGraphicsOpenGL extends PGraphics { // these vertices need to be duplicated at the end of the corresponding // region in the vertex array. void partitionRawIndices() { - tess.fillIndexCheck(rawSize); - int offset = tess.firstFillIndex; + tess.polyIndexCheck(rawSize); + int offset = tess.firstPolyIndex; int inInd0 = 0, inInd1 = 0; int inMaxVert0 = in.firstVertex, inMaxVert1 = in.firstVertex; int inMaxRel = 0; Set inDupSet = null; - IndexCache cache = tess.fillIndexCache; + IndexCache cache = tess.polyIndexCache; // In retained mode, each shape has with its own cache item, since // they should always be available to be rendererd individually, even // if contained in a larger hierarchy. int index = in.renderMode == RETAINED ? cache.addNew() : cache.getLast(); - firstFillIndexCache = index; + firstPolyIndexCache = index; int trCount = rawSize / 3; for (int tr = 0; tr < trCount; tr++) { @@ -10490,9 +10503,9 @@ public class PGraphicsOpenGL extends PGraphics { ri2 = ii2; } else ri2 = count + ii2; - tess.fillIndices[offset + 3 * tr + 0] = (short) ri0; - tess.fillIndices[offset + 3 * tr + 1] = (short) ri1; - tess.fillIndices[offset + 3 * tr + 2] = (short) ri2; + tess.polyIndices[offset + 3 * tr + 0] = (short) ri0; + tess.polyIndices[offset + 3 * tr + 1] = (short) ri1; + tess.polyIndices[offset + 3 * tr + 2] = (short) ri2; inInd1 = 3 * tr + 2; inMaxVert1 = PApplet.max(i0, i1, i2); @@ -10507,7 +10520,7 @@ public class PGraphicsOpenGL extends PGraphics { // so we need to wrap-up things anyways. // So, copy vertices in current region first - tess.addFillVertices(in, inMaxVert0, inMaxVert1); + tess.addPolyVertices(in, inMaxVert0, inMaxVert1); if (0 < dup) { // Adjusting the negative indices so they correspond to vertices added @@ -10515,22 +10528,22 @@ public class PGraphicsOpenGL extends PGraphics { ArrayList inDupList = new ArrayList(inDupSet); Collections.sort(inDupList); for (int i = inInd0; i <= inInd1; i++) { - int ri = tess.fillIndices[i]; + int ri = tess.polyIndices[i]; if (ri < 0) { - tess.fillIndices[i] = (short) (inMaxRel + 1 + inDupList.indexOf(ri)); + tess.polyIndices[i] = (short) (inMaxRel + 1 + inDupList.indexOf(ri)); } } // Copy duplicated vertices from previous regions last for (int i = 0; i < inDupList.size(); i++) { int ri = inDupList.get(i); - tess.addFillVertex(in, ri + inMaxVert0); + tess.addPolyVertex(in, ri + inMaxVert0); } } // Increment counts: cache.incCounts(index, inInd1 - inInd0 + 1, inMaxVert1 - inMaxVert0 + 1 + dup); - lastFillIndexCache = index; + lastPolyIndexCache = index; index = -1; inMaxRel = 0; @@ -10578,7 +10591,7 @@ public class PGraphicsOpenGL extends PGraphics { // Polygon tessellation void tessellatePolygon(boolean solid, boolean closed, boolean calcNormals) { - setFirstTexIndex(tess.fillIndexCount, tess.fillIndexCache.size - 1); + setFirstTexIndex(tess.polyIndexCount, tess.polyIndexCache.size - 1); int nInVert = in.lastVertex - in.firstVertex + 1; @@ -10588,7 +10601,7 @@ public class PGraphicsOpenGL extends PGraphics { // } if (fill && 3 <= nInVert) { - firstFillIndexCache = -1; + firstPolyIndexCache = -1; callback.init(in.renderMode == RETAINED, calcNormals); @@ -10634,7 +10647,7 @@ public class PGraphicsOpenGL extends PGraphics { int eb = (in.emissive[i] >> 0) & 0xFF; // Vertex data includes coordinates, colors, normals, texture coordinates, and material properties. - double[] vertex = new double[] { in.vertices [4 * i + 0], in.vertices [4 * i + 1], in.vertices[4 * i + 2], + double[] vertex = new double[] { in.vertices [3 * i + 0], in.vertices [3 * i + 1], in.vertices[3 * i + 2], fa, fr, fg, fb, in.normals [3 * i + 0], in.normals [3 * i + 1], in.normals [3 * i + 2], in.texcoords[2 * i + 0], in.texcoords[2 * i + 1], @@ -10648,7 +10661,7 @@ public class PGraphicsOpenGL extends PGraphics { gluTess.endPolygon(); } - setLastTexIndex(tess.lastFillIndex, tess.fillIndexCache.size - 1); + setLastTexIndex(tess.lastPolyIndex, tess.polyIndexCache.size - 1); tessellateEdges(fill && 3 <= nInVert); } @@ -10744,7 +10757,7 @@ public class PGraphicsOpenGL extends PGraphics { public void init(boolean add, boolean calcn) { calcNormals = calcn; - cache = tess.fillIndexCache; + cache = tess.polyIndexCache; if (add) { cache.addNew(); @@ -10755,8 +10768,8 @@ public class PGraphicsOpenGL extends PGraphics { //cacheIndex = in.renderMode == RETAINED ? cache.addNew() : cache.getLast(); cacheIndex = cache.getLast(); - if (cacheIndex < firstFillIndexCache || firstFillIndexCache == -1) { - firstFillIndexCache = cacheIndex; + if (cacheIndex < firstPolyIndexCache || firstPolyIndexCache == -1) { + firstPolyIndexCache = cacheIndex; } vertFirst = cache.vertexCount[cacheIndex]; @@ -10831,16 +10844,16 @@ public class PGraphicsOpenGL extends PGraphics { } cache.incCounts(cacheIndex, indCount, vertCount); - lastFillIndexCache = cacheIndex; + lastPolyIndexCache = cacheIndex; } protected void addIndex(int tessIdx) { - tess.fillIndexCheck(); - tess.fillIndices[tess.fillIndexCount - 1] = (short) (vertFirst + tessIdx); + tess.polyIndexCheck(); + tess.polyIndices[tess.polyIndexCount - 1] = (short) (vertFirst + tessIdx); } protected void calcTriNormal(int tessIdx0, int tessIdx1, int tessIdx2) { - tess.calcFillNormal(vertFirst + tessIdx0, vertFirst + tessIdx1, vertFirst + tessIdx2); + tess.calcPolyNormal(vertFirst + tessIdx0, vertFirst + tessIdx1, vertFirst + tessIdx2); } public void vertex(Object data) { @@ -10871,7 +10884,7 @@ public class PGraphicsOpenGL extends PGraphics { } } - tess.addFillVertex((float) d[ 0], (float) d[ 1], (float) d[ 2], 1, + tess.addPolyVertex((float) d[ 0], (float) d[ 1], (float) d[ 2], fcolor, (float) d[ 7], (float) d[ 8], (float) d[ 9], (float) d[10], (float) d[11], diff --git a/java/libraries/opengl/src/processing/opengl/PShader.java b/java/libraries/opengl/src/processing/opengl/PShader.java index b0dd78cb0..42a5f4ec6 100644 --- a/java/libraries/opengl/src/processing/opengl/PShader.java +++ b/java/libraries/opengl/src/processing/opengl/PShader.java @@ -1,14 +1,16 @@ /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ +/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ + /* Part of the Processing project - http://processing.org - Copyright (c) 2011 Andres Colubri - Copyright (c) 2010 Ben Fry and Casey Reas + Copyright (c) 2011-12 Ben Fry and Casey Reas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public - License version 2.1 as published by the Free Software Foundation. + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -19,7 +21,7 @@ Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ +*/ package processing.opengl; diff --git a/java/libraries/opengl/src/processing/opengl/PShapeOpenGL.java b/java/libraries/opengl/src/processing/opengl/PShapeOpenGL.java index 31b249c33..9fcb52c13 100644 --- a/java/libraries/opengl/src/processing/opengl/PShapeOpenGL.java +++ b/java/libraries/opengl/src/processing/opengl/PShapeOpenGL.java @@ -34,7 +34,7 @@ import processing.core.PShape; import processing.core.PVector; import processing.opengl.PGraphicsOpenGL.LineShader; import processing.opengl.PGraphicsOpenGL.PointShader; -import processing.opengl.PGraphicsOpenGL.FillShader; +import processing.opengl.PGraphicsOpenGL.PolyShader; import processing.opengl.PGraphicsOpenGL.IndexCache; import processing.opengl.PGraphicsOpenGL.InGeometry; import processing.opengl.PGraphicsOpenGL.TessGeometry; @@ -92,15 +92,15 @@ public class PShapeOpenGL extends PShape { // OpenGL buffers - public int glFillVertexBufferID; - public int glFillColorBufferID; - public int glFillNormalBufferID; - public int glFillTexCoordBufferID; - public int glFillAmbientBufferID; - public int glFillSpecularBufferID; - public int glFillEmissiveBufferID; - public int glFillShininessBufferID; - public int glFillIndexBufferID; + public int glPolyVertexBufferID; + public int glPolyColorBufferID; + public int glPolyNormalBufferID; + public int glPolyTexcoordBufferID; + public int glPolyAmbientBufferID; + public int glPolySpecularBufferID; + public int glPolyEmissiveBufferID; + public int glPolyShininessBufferID; + public int glPolyIndexBufferID; public int glLineVertexBufferID; public int glLineColorBufferID; @@ -116,17 +116,17 @@ public class PShapeOpenGL extends PShape { // Offsets for geometry aggregation and update. - protected int fillVertCopyOffset; - protected int fillIndCopyOffset; + protected int polyVertCopyOffset; + protected int polyIndCopyOffset; protected int lineVertCopyOffset; protected int lineIndCopyOffset; protected int pointVertCopyOffset; protected int pointIndCopyOffset; - protected int fillIndexOffset; - protected int fillVertexOffset; - protected int fillVertexAbs; - protected int fillVertexRel; + protected int polyIndexOffset; + protected int polyVertexOffset; + protected int polyVertexAbs; + protected int polyVertexRel; protected int lineIndexOffset; protected int lineVertexOffset; @@ -137,16 +137,16 @@ public class PShapeOpenGL extends PShape { protected int pointVertexOffset; protected int pointVertexAbs; protected int pointVertexRel; - - int firstPointIndexCache; - int lastPointIndexCache; - int firstLineIndexCache; - int lastLineIndexCache; - int firstFillIndexCache; - int lastFillIndexCache; + + protected int firstPolyIndexCache; + protected int lastpolyIndexCache; + protected int firstLineIndexCache; + protected int lastLineIndexCache; + protected int firstPointIndexCache; + protected int lastPointIndexCache; - protected int firstFillVertex; - protected int lastFillVertex; + protected int firstPolyVertex; + protected int lastPolyVertex; protected int firstLineVertex; protected int lastLineVertex; protected int firstPointVertex; @@ -173,7 +173,7 @@ public class PShapeOpenGL extends PShape { protected boolean breakShape = false; protected boolean shapeEnded = false; - protected boolean haveFill; + protected boolean havePolys; protected boolean haveLines; protected boolean havePoints; @@ -217,14 +217,14 @@ public class PShapeOpenGL extends PShape { protected boolean modified; - protected boolean modifiedFillVertices; - protected boolean modifiedFillColors; - protected boolean modifiedFillNormals; - protected boolean modifiedFillTexCoords; - protected boolean modifiedFillAmbient; - protected boolean modifiedFillSpecular; - protected boolean modifiedFillEmissive; - protected boolean modifiedFillShininess; + protected boolean modifiedPolyVertices; + protected boolean modifiedPolyColors; + protected boolean modifiedPolyNormals; + protected boolean modifiedPolyTexcoords; + protected boolean modifiedPolyAmbient; + protected boolean modifiedPolySpecular; + protected boolean modifiedPolyEmissive; + protected boolean modifiedPolyShininess; protected boolean modifiedLineVertices; protected boolean modifiedLineColors; @@ -234,22 +234,22 @@ public class PShapeOpenGL extends PShape { protected boolean modifiedPointColors; protected boolean modifiedPointAttributes; - protected int firstModifiedFillVertex; - protected int lastModifiedFillVertex; - protected int firstModifiedFillColor; - protected int lastModifiedFillColor; - protected int firstModifiedFillNormal; - protected int lastModifiedFillNormal; - protected int firstModifiedFillTexCoord; - protected int lastModifiedFillTexCoord; - protected int firstModifiedFillAmbient; - protected int lastModifiedFillAmbient; - protected int firstModifiedFillSpecular; - protected int lastModifiedFillSpecular; - protected int firstModifiedFillEmissive; - protected int lastModifiedFillEmissive; - protected int firstModifiedFillShininess; - protected int lastModifiedFillShininess; + protected int firstModifiedPolyVertex; + protected int lastModifiedPolyVertex; + protected int firstModifiedPolyColor; + protected int lastModifiedPolyColor; + protected int firstModifiedPolyNormal; + protected int lastModifiedPolyNormal; + protected int firstModifiedPolyTexcoord; + protected int lastModifiedPolyTexcoord; + protected int firstModifiedPolyAmbient; + protected int lastModifiedPolyAmbient; + protected int firstModifiedPolySpecular; + protected int lastModifiedPolySpecular; + protected int firstModifiedPolyEmissive; + protected int lastModifiedPolyEmissive; + protected int firstModifiedPolyShininess; + protected int lastModifiedPolyShininess; protected int firstModifiedLineVertex; protected int lastModifiedLineVertex; @@ -273,15 +273,15 @@ public class PShapeOpenGL extends PShape { pgl = pg.pgl; context = pgl.createEmptyContext(); - glFillVertexBufferID = 0; - glFillColorBufferID = 0; - glFillNormalBufferID = 0; - glFillTexCoordBufferID = 0; - glFillAmbientBufferID = 0; - glFillSpecularBufferID = 0; - glFillEmissiveBufferID = 0; - glFillShininessBufferID = 0; - glFillIndexBufferID = 0; + glPolyVertexBufferID = 0; + glPolyColorBufferID = 0; + glPolyNormalBufferID = 0; + glPolyTexcoordBufferID = 0; + glPolyAmbientBufferID = 0; + glPolySpecularBufferID = 0; + glPolyEmissiveBufferID = 0; + glPolyShininessBufferID = 0; + glPolyIndexBufferID = 0; glLineVertexBufferID = 0; glLineColorBufferID = 0; @@ -381,7 +381,7 @@ public class PShapeOpenGL extends PShape { protected void finalize() throws Throwable { try { - finalizeFillBuffers(); + finalizePolyBuffers(); finalizeLineBuffers(); finalizePointBuffers(); } finally { @@ -390,41 +390,41 @@ public class PShapeOpenGL extends PShape { } - protected void finalizeFillBuffers() { - if (glFillVertexBufferID != 0) { - pg.finalizeVertexBufferObject(glFillVertexBufferID, context.code()); + protected void finalizePolyBuffers() { + if (glPolyVertexBufferID != 0) { + pg.finalizeVertexBufferObject(glPolyVertexBufferID, context.code()); } - if (glFillColorBufferID != 0) { - pg.finalizeVertexBufferObject(glFillColorBufferID, context.code()); + if (glPolyColorBufferID != 0) { + pg.finalizeVertexBufferObject(glPolyColorBufferID, context.code()); } - if (glFillNormalBufferID != 0) { - pg.finalizeVertexBufferObject(glFillNormalBufferID, context.code()); + if (glPolyNormalBufferID != 0) { + pg.finalizeVertexBufferObject(glPolyNormalBufferID, context.code()); } - if (glFillTexCoordBufferID != 0) { - pg.finalizeVertexBufferObject(glFillTexCoordBufferID, context.code()); + if (glPolyTexcoordBufferID != 0) { + pg.finalizeVertexBufferObject(glPolyTexcoordBufferID, context.code()); } - if (glFillAmbientBufferID != 0) { - pg.finalizeVertexBufferObject(glFillAmbientBufferID, context.code()); + if (glPolyAmbientBufferID != 0) { + pg.finalizeVertexBufferObject(glPolyAmbientBufferID, context.code()); } - if (glFillSpecularBufferID != 0) { - pg.finalizeVertexBufferObject(glFillSpecularBufferID, context.code()); + if (glPolySpecularBufferID != 0) { + pg.finalizeVertexBufferObject(glPolySpecularBufferID, context.code()); } - if (glFillEmissiveBufferID != 0) { - pg.finalizeVertexBufferObject(glFillEmissiveBufferID, context.code()); + if (glPolyEmissiveBufferID != 0) { + pg.finalizeVertexBufferObject(glPolyEmissiveBufferID, context.code()); } - if (glFillShininessBufferID != 0) { - pg.finalizeVertexBufferObject(glFillShininessBufferID, context.code()); + if (glPolyShininessBufferID != 0) { + pg.finalizeVertexBufferObject(glPolyShininessBufferID, context.code()); } - if (glFillIndexBufferID != 0) { - pg.finalizeVertexBufferObject(glFillIndexBufferID, context.code()); + if (glPolyIndexBufferID != 0) { + pg.finalizeVertexBufferObject(glPolyIndexBufferID, context.code()); } } @@ -534,7 +534,7 @@ public class PShapeOpenGL extends PShape { child.getVertexMin(min); } } else { - if (haveFill) tessGeo.getFillVertexMin(min, firstFillVertex, lastFillVertex); + if (havePolys) tessGeo.getPolyVertexMin(min, firstPolyVertex, lastPolyVertex); if (haveLines) tessGeo.getLineVertexMin(min, firstLineVertex, lastLineVertex); if (havePoints) tessGeo.getPointVertexMin(min, firstPointVertex, lastPointVertex); } @@ -550,7 +550,7 @@ public class PShapeOpenGL extends PShape { child.getVertexMax(max); } } else { - if (haveFill) tessGeo.getFillVertexMax(max, firstFillVertex, lastFillVertex); + if (havePolys) tessGeo.getPolyVertexMax(max, firstPolyVertex, lastPolyVertex); if (haveLines) tessGeo.getLineVertexMax(max, firstLineVertex, lastLineVertex); if (havePoints) tessGeo.getPointVertexMax(max, firstPointVertex, lastPointVertex); } @@ -566,7 +566,7 @@ public class PShapeOpenGL extends PShape { count += child.getVertexSum(sum, count); } } else { - if (haveFill) count += tessGeo.getFillVertexSum(sum, firstFillVertex, lastFillVertex); + if (havePolys) count += tessGeo.getPolyVertexSum(sum, firstPolyVertex, lastPolyVertex); if (haveLines) count += tessGeo.getLineVertexSum(sum, firstLineVertex, lastLineVertex); if (havePoints) count += tessGeo.getPointVertexSum(sum, firstPointVertex, lastPointVertex); } @@ -1028,10 +1028,10 @@ public class PShapeOpenGL extends PShape { protected void updateFillColor() { - if (shapeEnded && tessellated && haveFill && texture == null) { + if (shapeEnded && tessellated && havePolys && texture == null) { Arrays.fill(inGeo.colors, 0, inGeo.vertexCount, PGL.javaToNativeARGB(fillColor)); - Arrays.fill(tessGeo.fillColors, firstFillVertex, lastFillVertex + 1, PGL.javaToNativeARGB(fillColor)); - root.setModifiedFillColors(firstFillVertex, lastFillVertex); + Arrays.fill(tessGeo.polyColors, firstPolyVertex, lastPolyVertex + 1, PGL.javaToNativeARGB(fillColor)); + root.setModifiedPolyColors(firstPolyVertex, lastPolyVertex); } } @@ -1260,10 +1260,10 @@ public class PShapeOpenGL extends PShape { protected void updateTintColor() { - if (shapeEnded && tessellated && haveFill && texture != null) { + if (shapeEnded && tessellated && havePolys && texture != null) { Arrays.fill(inGeo.colors, 0, inGeo.vertexCount, PGL.javaToNativeARGB(tintColor)); - Arrays.fill(tessGeo.fillColors, firstFillVertex, lastFillVertex + 1, PGL.javaToNativeARGB(tintColor)); - root.setModifiedFillColors(firstFillVertex, lastFillVertex); + Arrays.fill(tessGeo.polyColors, firstPolyVertex, lastPolyVertex + 1, PGL.javaToNativeARGB(tintColor)); + root.setModifiedPolyColors(firstPolyVertex, lastPolyVertex); } } @@ -1319,10 +1319,10 @@ public class PShapeOpenGL extends PShape { protected void updateAmbientColor() { - if (shapeEnded && tessellated && haveFill) { + if (shapeEnded && tessellated && havePolys) { Arrays.fill(inGeo.ambient, 0, inGeo.vertexCount, PGL.javaToNativeARGB(ambientColor)); - Arrays.fill(tessGeo.fillAmbient, firstFillVertex, lastFillVertex = 1, PGL.javaToNativeARGB(ambientColor)); - root.setModifiedFillAmbient(firstFillVertex, lastFillVertex); + Arrays.fill(tessGeo.polyAmbient, firstPolyVertex, lastPolyVertex = 1, PGL.javaToNativeARGB(ambientColor)); + root.setModifiedPolyAmbient(firstPolyVertex, lastPolyVertex); } } @@ -1378,10 +1378,10 @@ public class PShapeOpenGL extends PShape { protected void updateSpecularColor() { - if (shapeEnded && tessellated && haveFill) { + if (shapeEnded && tessellated && havePolys) { Arrays.fill(inGeo.specular, 0, inGeo.vertexCount, PGL.javaToNativeARGB(specularColor)); - Arrays.fill(tessGeo.fillSpecular, firstFillVertex, lastFillVertex + 1, PGL.javaToNativeARGB(specularColor)); - root.setModifiedFillSpecular(firstFillVertex, lastFillVertex); + Arrays.fill(tessGeo.polySpecular, firstPolyVertex, lastPolyVertex + 1, PGL.javaToNativeARGB(specularColor)); + root.setModifiedPolySpecular(firstPolyVertex, lastPolyVertex); } } @@ -1437,10 +1437,10 @@ public class PShapeOpenGL extends PShape { protected void updateEmissiveColor() { - if (shapeEnded && tessellated && 0 < tessGeo.fillVertexCount) { + if (shapeEnded && tessellated && 0 < tessGeo.polyVertexCount) { Arrays.fill(inGeo.emissive, 0, inGeo.vertexCount, PGL.javaToNativeARGB(emissiveColor)); - Arrays.fill(tessGeo.fillEmissive, firstFillVertex, lastFillVertex + 1, PGL.javaToNativeARGB(emissiveColor)); - root.setModifiedFillEmissive(firstFillVertex, lastFillVertex); + Arrays.fill(tessGeo.polyEmissive, firstPolyVertex, lastPolyVertex + 1, PGL.javaToNativeARGB(emissiveColor)); + root.setModifiedPolyEmissive(firstPolyVertex, lastPolyVertex); } } @@ -1464,10 +1464,10 @@ public class PShapeOpenGL extends PShape { protected void updateShininessFactor() { - if (shapeEnded && tessellated && haveFill) { + if (shapeEnded && tessellated && havePolys) { Arrays.fill(inGeo.shininess, 0, inGeo.vertexCount, shininess); - Arrays.fill(tessGeo.fillShininess, firstFillVertex, lastFillVertex + 1, shininess); - root.setModifiedFillShininess(firstFillVertex, lastFillVertex); + Arrays.fill(tessGeo.polyShininess, firstPolyVertex, lastPolyVertex + 1, shininess); + root.setModifiedPolyShininess(firstPolyVertex, lastPolyVertex); } } @@ -1633,10 +1633,10 @@ public class PShapeOpenGL extends PShape { protected void applyMatrixImpl(PMatrix matrix) { - if (haveFill) { - tessGeo.applyMatrixOnFillGeometry(matrix, firstFillVertex, lastFillVertex); - root.setModifiedFillVertices(firstFillVertex, lastFillVertex); - root.setModifiedFillNormals(firstFillVertex, lastFillVertex); + if (havePolys) { + tessGeo.applyMatrixOnPolyGeometry(matrix, firstPolyVertex, lastPolyVertex); + root.setModifiedPolyVertices(firstPolyVertex, lastPolyVertex); + root.setModifiedPolyNormals(firstPolyVertex, lastPolyVertex); } if (haveLines) { @@ -1756,9 +1756,9 @@ public class PShapeOpenGL extends PShape { if (vec == null) { vec = new PVector(); } - vec.x = inGeo.vertices[4 * index + 0]; - vec.y = inGeo.vertices[4 * index + 1]; - vec.z = inGeo.vertices[4 * index + 2]; + vec.x = inGeo.vertices[3 * index + 0]; + vec.y = inGeo.vertices[3 * index + 1]; + vec.z = inGeo.vertices[3 * index + 2]; return vec; } @@ -1766,22 +1766,22 @@ public class PShapeOpenGL extends PShape { public float getVertexX(int index) { updateTessellation(); - return inGeo.vertices[4 * index + 0]; + return inGeo.vertices[3 * index + 0]; } public float getVertexY(int index) { updateTessellation(); - return inGeo.vertices[4 * index + 1]; + return inGeo.vertices[3 * index + 1]; } public float getVertexZ(int index) { updateTessellation(); - return inGeo.vertices[4 * index + 2]; - } + return inGeo.vertices[3 * index + 2]; + } public void setVertex(int index, float x, float y) { @@ -1792,6 +1792,7 @@ public class PShapeOpenGL extends PShape { public void setVertex(int index, float x, float y, float z) { updateTessellation(); + /* int[] indices; int[] indices1; float[] vertices; @@ -1830,7 +1831,7 @@ public class PShapeOpenGL extends PShape { } if (haveFill) { - vertices = tessGeo.fillVertices; + vertices = tessGeo.polyVertices; if (-1 < inGeo.tessMap.firstFillIndex) { // 1-1 mapping, only need to offset the input index int tessIdx = inGeo.tessMap.firstFillIndex + index; @@ -1874,10 +1875,10 @@ public class PShapeOpenGL extends PShape { } } } - - inGeo.vertices[4 * index + 0] = x; - inGeo.vertices[4 * index + 1] = y; - inGeo.vertices[4 * index + 2] = z; +*/ + inGeo.vertices[3 * index + 0] = x; + inGeo.vertices[3 * index + 1] = y; + inGeo.vertices[3 * index + 2] = z; } @@ -1917,9 +1918,9 @@ public class PShapeOpenGL extends PShape { public void setNormal(int index, float nx, float ny, float nz) { updateTessellation(); - + /* if (haveFill) { - float[] normals = tessGeo.fillNormals; + float[] normals = tessGeo.polyNormals; if (-1 < inGeo.tessMap.firstFillIndex) { int tessIdx = inGeo.tessMap.firstFillIndex + index; @@ -1960,7 +1961,7 @@ public class PShapeOpenGL extends PShape { } } } - + */ inGeo.normals[3 * index + 0] = nx; inGeo.normals[3 * index + 1] = ny; inGeo.normals[3 * index + 2] = nz; @@ -1983,14 +1984,14 @@ public class PShapeOpenGL extends PShape { public void setTextureUV(int index, float u, float v) { updateTessellation(); - + /* if (haveFill) { - float[] texcoords = tessGeo.fillTexcoords; + float[] texcoords = tessGeo.polyTexcoords; if (-1 < inGeo.tessMap.firstFillIndex) { int tessIdx = inGeo.tessMap.firstFillIndex + index; - tessGeo.fillTexcoords[2 * tessIdx + 0] = u; - tessGeo.fillTexcoords[2 * tessIdx + 1] = v; + tessGeo.polyTexcoords[2 * tessIdx + 0] = u; + tessGeo.polyTexcoords[2 * tessIdx + 1] = v; root.setModifiedFillTexcoords(tessIdx, tessIdx); } else { float u0 = inGeo.texcoords[2 * index + 0]; @@ -2012,7 +2013,7 @@ public class PShapeOpenGL extends PShape { } } } - + */ inGeo.texcoords[2 * index + 0] = u; inGeo.texcoords[2 * index + 1] = v; } @@ -2029,9 +2030,9 @@ public class PShapeOpenGL extends PShape { updateTessellation(); fill = PGL.javaToNativeARGB(fill); - +/* if (haveFill) { - int[] colors = tessGeo.fillColors; + int[] colors = tessGeo.polyColors; if (-1 < inGeo.tessMap.firstFillIndex) { int tessIdx = inGeo.tessMap.firstFillIndex + index; @@ -2050,7 +2051,7 @@ public class PShapeOpenGL extends PShape { } } } - + */ inGeo.colors[index] = fill; } @@ -2064,9 +2065,9 @@ public class PShapeOpenGL extends PShape { public void setStroke(int index, int stroke) { updateTessellation(); - + stroke = PGL.javaToNativeARGB(stroke); - + /* if (havePoints) { int[] indices = inGeo.tessMap.pointIndices[index]; int[] colors = tessGeo.pointColors; @@ -2092,7 +2093,7 @@ public class PShapeOpenGL extends PShape { root.setModifiedLineColors(tessIdx, tessIdx); } } - + */ inGeo.scolors[index] = stroke; } @@ -2106,7 +2107,7 @@ public class PShapeOpenGL extends PShape { public void setStrokeWeight(int index, float weight) { updateTessellation(); - + /* if (havePoints || haveLines) { int[] indices; float[] attribs; @@ -2141,7 +2142,7 @@ public class PShapeOpenGL extends PShape { } } } - + */ inGeo.sweights[index] = weight; } @@ -2157,9 +2158,9 @@ public class PShapeOpenGL extends PShape { updateTessellation(); ambient = PGL.javaToNativeARGB(ambient); - + /* if (haveFill) { - int[] colors = tessGeo.fillAmbient; + int[] colors = tessGeo.polyAmbient; if (-1 < inGeo.tessMap.firstFillIndex) { int tessIdx = inGeo.tessMap.firstFillIndex + index; @@ -2178,7 +2179,7 @@ public class PShapeOpenGL extends PShape { } } } - + */ inGeo.ambient[index] = ambient; } @@ -2193,9 +2194,9 @@ public class PShapeOpenGL extends PShape { updateTessellation(); specular = PGL.javaToNativeARGB(specular); - + /* if (haveFill) { - int[] colors = tessGeo.fillSpecular; + int[] colors = tessGeo.polySpecular; if (-1 < inGeo.tessMap.firstFillIndex) { int tessIdx = inGeo.tessMap.firstFillIndex + index; @@ -2214,7 +2215,7 @@ public class PShapeOpenGL extends PShape { } } } - + */ inGeo.specular[index] = specular; } @@ -2230,9 +2231,9 @@ public class PShapeOpenGL extends PShape { updateTessellation(); emissive = PGL.javaToNativeARGB(emissive); - + /* if (haveFill) { - int[] colors = tessGeo.fillEmissive; + int[] colors = tessGeo.polyEmissive; if (-1 < inGeo.tessMap.firstFillIndex) { int tessIdx = inGeo.tessMap.firstFillIndex + index; @@ -2251,7 +2252,7 @@ public class PShapeOpenGL extends PShape { } } } - + */ inGeo.emissive[index] = emissive; } @@ -2265,9 +2266,9 @@ public class PShapeOpenGL extends PShape { public void setShininess(int index, float shine) { updateTessellation(); - + /* if (haveFill) { - float[] shininess = tessGeo.fillShininess; + float[] shininess = tessGeo.polyShininess; if (-1 < inGeo.tessMap.firstFillIndex) { int tessIdx = inGeo.tessMap.firstFillIndex + index; @@ -2289,11 +2290,11 @@ public class PShapeOpenGL extends PShape { } } } - + */ inGeo.shininess[index] = shine; } - + /* protected void setColorARGB(int[] colors, int fill, int fill0, int[] indices, float[] weights) { float a = (fill >> 24) & 0xFF; float r = (fill >> 16) & 0xFF; @@ -2352,7 +2353,7 @@ public class PShapeOpenGL extends PShape { } } } - + */ /////////////////////////////////////////////////////////// @@ -2364,17 +2365,17 @@ public class PShapeOpenGL extends PShape { public PShape getTessellation() { updateTessellation(); - float[] vertices = tessGeo.fillVertices; - float[] normals = tessGeo.fillNormals; - int[] color = tessGeo.fillColors; - float[] uv = tessGeo.fillTexcoords; - short[] indices = tessGeo.fillIndices; + float[] vertices = tessGeo.polyVertices; + float[] normals = tessGeo.polyNormals; + int[] color = tessGeo.polyColors; + float[] uv = tessGeo.polyTexcoords; + short[] indices = tessGeo.polyIndices; PShape tess = pg.createShape(TRIANGLES); tess.noStroke(); - IndexCache cache = tessGeo.fillIndexCache; - for (int n = firstFillIndexCache; n <= lastFillIndexCache; n++) { + IndexCache cache = tessGeo.polyIndexCache; + for (int n = firstPolyIndexCache; n <= lastpolyIndexCache; n++) { int ioffset = cache.indexOffset[n]; int icount = cache.indexCount[n]; int voffset = cache.vertexOffset[n]; @@ -2458,14 +2459,14 @@ public class PShapeOpenGL extends PShape { modified = false; - modifiedFillVertices = false; - modifiedFillColors = false; - modifiedFillNormals = false; - modifiedFillTexCoords = false; - modifiedFillAmbient = false; - modifiedFillSpecular = false; - modifiedFillEmissive = false; - modifiedFillShininess = false; + modifiedPolyVertices = false; + modifiedPolyColors = false; + modifiedPolyNormals = false; + modifiedPolyTexcoords = false; + modifiedPolyAmbient = false; + modifiedPolySpecular = false; + modifiedPolyEmissive = false; + modifiedPolyShininess = false; modifiedLineVertices = false; modifiedLineColors = false; @@ -2475,22 +2476,22 @@ public class PShapeOpenGL extends PShape { modifiedPointColors = false; modifiedPointAttributes = false; - firstModifiedFillVertex = PConstants.MAX_INT; - lastModifiedFillVertex = PConstants.MIN_INT; - firstModifiedFillColor = PConstants.MAX_INT; - lastModifiedFillColor = PConstants.MIN_INT; - firstModifiedFillNormal = PConstants.MAX_INT; - lastModifiedFillNormal = PConstants.MIN_INT; - firstModifiedFillTexCoord = PConstants.MAX_INT; - lastModifiedFillTexCoord = PConstants.MIN_INT; - firstModifiedFillAmbient = PConstants.MAX_INT; - lastModifiedFillAmbient = PConstants.MIN_INT; - firstModifiedFillSpecular = PConstants.MAX_INT; - lastModifiedFillSpecular = PConstants.MIN_INT; - firstModifiedFillEmissive = PConstants.MAX_INT; - lastModifiedFillEmissive = PConstants.MIN_INT; - firstModifiedFillShininess = PConstants.MAX_INT; - lastModifiedFillShininess = PConstants.MIN_INT; + firstModifiedPolyVertex = PConstants.MAX_INT; + lastModifiedPolyVertex = PConstants.MIN_INT; + firstModifiedPolyColor = PConstants.MAX_INT; + lastModifiedPolyColor = PConstants.MIN_INT; + firstModifiedPolyNormal = PConstants.MAX_INT; + lastModifiedPolyNormal = PConstants.MIN_INT; + firstModifiedPolyTexcoord = PConstants.MAX_INT; + lastModifiedPolyTexcoord = PConstants.MIN_INT; + firstModifiedPolyAmbient = PConstants.MAX_INT; + lastModifiedPolyAmbient = PConstants.MIN_INT; + firstModifiedPolySpecular = PConstants.MAX_INT; + lastModifiedPolySpecular = PConstants.MIN_INT; + firstModifiedPolyEmissive = PConstants.MAX_INT; + lastModifiedPolyEmissive = PConstants.MIN_INT; + firstModifiedPolyShininess = PConstants.MAX_INT; + lastModifiedPolyShininess = PConstants.MIN_INT; firstModifiedLineVertex = PConstants.MAX_INT; lastModifiedLineVertex = PConstants.MIN_INT; @@ -2522,8 +2523,8 @@ public class PShapeOpenGL extends PShape { lastPointIndexCache = -1; firstLineIndexCache = -1; lastLineIndexCache = -1; - firstFillIndexCache = -1; - lastFillIndexCache = -1; + firstPolyIndexCache = -1; + lastpolyIndexCache = -1; } else { if (shapeEnded) { // If the geometry was tessellated previously, then @@ -2620,8 +2621,8 @@ public class PShapeOpenGL extends PShape { lastPointIndexCache = tessellator.lastPointIndexCache; firstLineIndexCache = tessellator.firstLineIndexCache; lastLineIndexCache = tessellator.lastLineIndexCache; - firstFillIndexCache = tessellator.firstFillIndexCache; - lastFillIndexCache = tessellator.lastFillIndexCache; + firstPolyIndexCache = tessellator.firstPolyIndexCache; + lastpolyIndexCache = tessellator.lastPolyIndexCache; } } @@ -2980,10 +2981,10 @@ public class PShapeOpenGL extends PShape { if (root == this && parent == null) { // Initializing auxiliary variables in root node // needed for aggregation. - fillIndexOffset = 0; - fillVertexOffset = 0; - fillVertexAbs = 0; - fillVertexRel = 0; + polyIndexOffset = 0; + polyVertexOffset = 0; + polyVertexAbs = 0; + polyVertexRel = 0; lineIndexOffset = 0; lineVertexOffset = 0; @@ -3031,23 +3032,23 @@ public class PShapeOpenGL extends PShape { protected void aggregateImpl() { if (family == GROUP) { // Recursively aggregating the child shapes. - haveFill = false; + havePolys = false; haveLines = false; havePoints = false; for (int i = 0; i < childCount; i++) { PShapeOpenGL child = (PShapeOpenGL) children[i]; child.aggregateImpl(); - haveFill |= child.haveFill; + havePolys |= child.havePolys; haveLines |= child.haveLines; havePoints |= child.havePoints; } } else { // LEAF SHAPE (family either GEOMETRY, PATH or PRIMITIVE) - haveFill = -1 < firstFillIndexCache && -1 < lastFillIndexCache; + havePolys = -1 < firstPolyIndexCache && -1 < lastpolyIndexCache; haveLines = -1 < firstLineIndexCache && -1 < lastLineIndexCache; havePoints = -1 < firstPointIndexCache && -1 < lastPointIndexCache; } - if (haveFill) updateFillIndexCache(); + if (havePolys) updatePolyIndexCache(); if (haveLines) updateLineIndexCache(); if (havePoints) updatePointIndexCache(); @@ -3055,7 +3056,7 @@ public class PShapeOpenGL extends PShape { // Some geometric transformations were applied on // this shape before tessellation, so they are applied now. //applyMatrixImpl(matrix); - if (haveFill) tessGeo.applyMatrixOnFillGeometry(matrix, firstFillVertex, lastFillVertex); + if (havePolys) tessGeo.applyMatrixOnPolyGeometry(matrix, firstPolyVertex, lastPolyVertex); if (haveLines) tessGeo.applyMatrixOnLineGeometry(matrix, firstLineVertex, lastLineVertex); if (havePoints) tessGeo.applyMatrixOnPointGeometry(matrix, firstPointVertex, lastPointVertex); } @@ -3063,8 +3064,8 @@ public class PShapeOpenGL extends PShape { // Updates the index cache for the range that corresponds to this shape. - protected void updateFillIndexCache() { - IndexCache cache = tessGeo.fillIndexCache; + protected void updatePolyIndexCache() { + IndexCache cache = tessGeo.polyIndexCache; if (family == GROUP) { // Updates the index cache to include the elements corresponding to // a group shape, using the cache entries of the child shapes. The @@ -3078,18 +3079,18 @@ public class PShapeOpenGL extends PShape { // The index ranges of the child shapes that share the vertex offset // are unified into a single range in the parent level. - firstFillIndexCache = lastFillIndexCache = -1; + firstPolyIndexCache = lastpolyIndexCache = -1; int gindex = -1; for (int i = 0; i < childCount; i++) { PShapeOpenGL child = (PShapeOpenGL) children[i]; - int first = child.firstFillIndexCache; - int count = -1 < first ? child.lastFillIndexCache - first + 1 : -1; + int first = child.firstPolyIndexCache; + int count = -1 < first ? child.lastpolyIndexCache - first + 1 : -1; for (int n = first; n < first + count; n++) { if (gindex == -1) { gindex = cache.addNew(n); - firstFillIndexCache = gindex; + firstPolyIndexCache = gindex; } else { if (cache.vertexOffset[gindex] == cache.vertexOffset[n]) { // When the vertex offsets are the same, this means that the @@ -3104,17 +3105,17 @@ public class PShapeOpenGL extends PShape { } } } - lastFillIndexCache = gindex; + lastpolyIndexCache = gindex; - if (-1 < firstFillIndexCache && -1 < lastFillIndexCache) { - firstFillVertex = cache.vertexOffset[firstFillIndexCache]; - lastFillVertex = cache.vertexOffset[lastFillIndexCache] + cache.vertexCount[lastFillIndexCache] - 1; + if (-1 < firstPolyIndexCache && -1 < lastpolyIndexCache) { + firstPolyVertex = cache.vertexOffset[firstPolyIndexCache]; + lastPolyVertex = cache.vertexOffset[lastpolyIndexCache] + cache.vertexCount[lastpolyIndexCache] - 1; } } else { // The index cache is updated in order to reflect the fact that all // the vertices will be stored in a single VBO in the root shape. // This update works as follows (the methodology is the same for - // fill, line and point): the VertexAbs variable in the root shape + // poly, line and point): the VertexAbs variable in the root shape // stores the index of the last vertex up to this shape (plus one) // without taking into consideration the MAX_VERTEX_INDEX limit, so // it effectively runs over the entire range. @@ -3123,25 +3124,25 @@ public class PShapeOpenGL extends PShape { // root shape. When this happens, the indices in the child shape need // to be restarted as well to reflect the new index offset. - firstFillVertex = lastFillVertex = cache.vertexOffset[firstFillIndexCache]; - for (int n = firstFillIndexCache; n <= lastFillIndexCache; n++) { + firstPolyVertex = lastPolyVertex = cache.vertexOffset[firstPolyIndexCache]; + for (int n = firstPolyIndexCache; n <= lastpolyIndexCache; n++) { int ioffset = cache.indexOffset[n]; int icount = cache.indexCount[n]; int vcount = cache.vertexCount[n]; - if (PGL.MAX_VERTEX_INDEX1 <= root.fillVertexRel + vcount) { - root.fillVertexRel = 0; - root.fillVertexOffset = root.fillVertexAbs; - cache.indexOffset[n] = root.fillIndexOffset; - } else tessGeo.incFillIndices(ioffset, ioffset + icount - 1, root.fillVertexRel); - cache.vertexOffset[n] = root.fillVertexOffset; + if (PGL.MAX_VERTEX_INDEX1 <= root.polyVertexRel + vcount) { + root.polyVertexRel = 0; + root.polyVertexOffset = root.polyVertexAbs; + cache.indexOffset[n] = root.polyIndexOffset; + } else tessGeo.incPolyIndices(ioffset, ioffset + icount - 1, root.polyVertexRel); + cache.vertexOffset[n] = root.polyVertexOffset; - root.fillIndexOffset += icount; - root.fillVertexAbs += vcount; - root.fillVertexRel += vcount; - lastFillVertex += vcount; + root.polyIndexOffset += icount; + root.polyVertexAbs += vcount; + root.polyVertexRel += vcount; + lastPolyVertex += vcount; } - lastFillVertex--; + lastPolyVertex--; } } @@ -3270,8 +3271,8 @@ public class PShapeOpenGL extends PShape { if (needBufferInit) { context = pgl.getCurrentContext(); - if (0 < tessGeo.fillVertexCount && 0 < tessGeo.fillIndexCount) { - initFillBuffers(); + if (0 < tessGeo.polyVertexCount && 0 < tessGeo.polyIndexCount) { + initPolyBuffers(); } if (0 < tessGeo.lineVertexCount && 0 < tessGeo.lineIndexCount) { @@ -3287,49 +3288,49 @@ public class PShapeOpenGL extends PShape { } - protected void initFillBuffers() { - int size = tessGeo.fillVertexCount; + protected void initPolyBuffers() { + int size = tessGeo.polyVertexCount; int sizef = size * PGL.SIZEOF_FLOAT; int sizei = size * PGL.SIZEOF_INT; - glFillVertexBufferID = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillVertexBufferID); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 4 * sizef, FloatBuffer.wrap(tessGeo.fillVertices, 0, 4 * size), PGL.GL_STATIC_DRAW); + glPolyVertexBufferID = pg.createVertexBufferObject(context.code()); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyVertexBufferID); + pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 4 * sizef, FloatBuffer.wrap(tessGeo.polyVertices, 0, 4 * size), PGL.GL_STATIC_DRAW); - glFillColorBufferID = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillColorBufferID); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.fillColors, 0, size), PGL.GL_STATIC_DRAW); + glPolyColorBufferID = pg.createVertexBufferObject(context.code()); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyColorBufferID); + pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polyColors, 0, size), PGL.GL_STATIC_DRAW); - glFillNormalBufferID = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillNormalBufferID); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 3 * sizef, FloatBuffer.wrap(tessGeo.fillNormals, 0, 3 * size), PGL.GL_STATIC_DRAW); + glPolyNormalBufferID = pg.createVertexBufferObject(context.code()); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyNormalBufferID); + pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 3 * sizef, FloatBuffer.wrap(tessGeo.polyNormals, 0, 3 * size), PGL.GL_STATIC_DRAW); - glFillTexCoordBufferID = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillTexCoordBufferID); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 2 * sizef, FloatBuffer.wrap(tessGeo.fillTexcoords, 0, 2 * size), PGL.GL_STATIC_DRAW); + glPolyTexcoordBufferID = pg.createVertexBufferObject(context.code()); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyTexcoordBufferID); + pgl.glBufferData(PGL.GL_ARRAY_BUFFER, 2 * sizef, FloatBuffer.wrap(tessGeo.polyTexcoords, 0, 2 * size), PGL.GL_STATIC_DRAW); - glFillAmbientBufferID = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillAmbientBufferID); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.fillAmbient, 0, size), PGL.GL_STATIC_DRAW); + glPolyAmbientBufferID = pg.createVertexBufferObject(context.code()); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyAmbientBufferID); + pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polyAmbient, 0, size), PGL.GL_STATIC_DRAW); - glFillSpecularBufferID = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillSpecularBufferID); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.fillSpecular, 0, size), PGL.GL_STATIC_DRAW); + glPolySpecularBufferID = pg.createVertexBufferObject(context.code()); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolySpecularBufferID); + pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polySpecular, 0, size), PGL.GL_STATIC_DRAW); - glFillEmissiveBufferID = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillEmissiveBufferID); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.fillEmissive, 0, size), PGL.GL_STATIC_DRAW); + glPolyEmissiveBufferID = pg.createVertexBufferObject(context.code()); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyEmissiveBufferID); + pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizei, IntBuffer.wrap(tessGeo.polyEmissive, 0, size), PGL.GL_STATIC_DRAW); - glFillShininessBufferID = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillShininessBufferID); - pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizef, FloatBuffer.wrap(tessGeo.fillShininess, 0, size), PGL.GL_STATIC_DRAW); + glPolyShininessBufferID = pg.createVertexBufferObject(context.code()); + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyShininessBufferID); + pgl.glBufferData(PGL.GL_ARRAY_BUFFER, sizef, FloatBuffer.wrap(tessGeo.polyShininess, 0, size), PGL.GL_STATIC_DRAW); pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); - glFillIndexBufferID = pg.createVertexBufferObject(context.code()); - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, glFillIndexBufferID); - pgl.glBufferData(PGL.GL_ELEMENT_ARRAY_BUFFER, tessGeo.fillIndexCount * PGL.SIZEOF_INDEX, - ShortBuffer.wrap(tessGeo.fillIndices, 0, tessGeo.fillIndexCount), PGL.GL_STATIC_DRAW); + glPolyIndexBufferID = pg.createVertexBufferObject(context.code()); + pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, glPolyIndexBufferID); + pgl.glBufferData(PGL.GL_ELEMENT_ARRAY_BUFFER, tessGeo.polyIndexCount * PGL.SIZEOF_INDEX, + ShortBuffer.wrap(tessGeo.polyIndices, 0, tessGeo.polyIndexCount), PGL.GL_STATIC_DRAW); pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, 0); } @@ -3398,15 +3399,15 @@ public class PShapeOpenGL extends PShape { // doesn't get deleted by OpenGL. The VBOs were already // automatically disposed when the old context was // destroyed. - pg.removeVertexBufferObject(glFillVertexBufferID, context.code()); - pg.removeVertexBufferObject(glFillColorBufferID, context.code()); - pg.removeVertexBufferObject(glFillNormalBufferID, context.code()); - pg.removeVertexBufferObject(glFillTexCoordBufferID, context.code()); - pg.removeVertexBufferObject(glFillAmbientBufferID, context.code()); - pg.removeVertexBufferObject(glFillSpecularBufferID, context.code()); - pg.removeVertexBufferObject(glFillEmissiveBufferID, context.code()); - pg.removeVertexBufferObject(glFillShininessBufferID, context.code()); - pg.removeVertexBufferObject(glFillIndexBufferID, context.code()); + pg.removeVertexBufferObject(glPolyVertexBufferID, context.code()); + pg.removeVertexBufferObject(glPolyColorBufferID, context.code()); + pg.removeVertexBufferObject(glPolyNormalBufferID, context.code()); + pg.removeVertexBufferObject(glPolyTexcoordBufferID, context.code()); + pg.removeVertexBufferObject(glPolyAmbientBufferID, context.code()); + pg.removeVertexBufferObject(glPolySpecularBufferID, context.code()); + pg.removeVertexBufferObject(glPolyEmissiveBufferID, context.code()); + pg.removeVertexBufferObject(glPolyShininessBufferID, context.code()); + pg.removeVertexBufferObject(glPolyIndexBufferID, context.code()); pg.removeVertexBufferObject(glLineVertexBufferID, context.code()); pg.removeVertexBufferObject(glLineColorBufferID, context.code()); @@ -3422,15 +3423,15 @@ public class PShapeOpenGL extends PShape { // when the context changed. We only need to zero // them to avoid deleting them again when the GC // runs the finalizers of the disposed object. - glFillVertexBufferID = 0; - glFillColorBufferID = 0; - glFillNormalBufferID = 0; - glFillTexCoordBufferID = 0; - glFillAmbientBufferID = 0; - glFillSpecularBufferID = 0; - glFillEmissiveBufferID = 0; - glFillShininessBufferID = 0; - glFillIndexBufferID = 0; + glPolyVertexBufferID = 0; + glPolyColorBufferID = 0; + glPolyNormalBufferID = 0; + glPolyTexcoordBufferID = 0; + glPolyAmbientBufferID = 0; + glPolySpecularBufferID = 0; + glPolyEmissiveBufferID = 0; + glPolyShininessBufferID = 0; + glPolyIndexBufferID = 0; glLineVertexBufferID = 0; glLineColorBufferID = 0; @@ -3454,56 +3455,56 @@ public class PShapeOpenGL extends PShape { protected void release() { - deleteFillBuffers(); + deletePolyBuffers(); deleteLineBuffers(); deletePointBuffers(); } - protected void deleteFillBuffers() { - if (glFillVertexBufferID != 0) { - pg.deleteVertexBufferObject(glFillVertexBufferID, context.code()); - glFillVertexBufferID = 0; + protected void deletePolyBuffers() { + if (glPolyVertexBufferID != 0) { + pg.deleteVertexBufferObject(glPolyVertexBufferID, context.code()); + glPolyVertexBufferID = 0; } - if (glFillColorBufferID != 0) { - pg.deleteVertexBufferObject(glFillColorBufferID, context.code()); - glFillColorBufferID = 0; + if (glPolyColorBufferID != 0) { + pg.deleteVertexBufferObject(glPolyColorBufferID, context.code()); + glPolyColorBufferID = 0; } - if (glFillNormalBufferID != 0) { - pg.deleteVertexBufferObject(glFillNormalBufferID, context.code()); - glFillNormalBufferID = 0; + if (glPolyNormalBufferID != 0) { + pg.deleteVertexBufferObject(glPolyNormalBufferID, context.code()); + glPolyNormalBufferID = 0; } - if (glFillTexCoordBufferID != 0) { - pg.deleteVertexBufferObject(glFillTexCoordBufferID, context.code()); - glFillTexCoordBufferID = 0; + if (glPolyTexcoordBufferID != 0) { + pg.deleteVertexBufferObject(glPolyTexcoordBufferID, context.code()); + glPolyTexcoordBufferID = 0; } - if (glFillAmbientBufferID != 0) { - pg.deleteVertexBufferObject(glFillAmbientBufferID, context.code()); - glFillAmbientBufferID = 0; + if (glPolyAmbientBufferID != 0) { + pg.deleteVertexBufferObject(glPolyAmbientBufferID, context.code()); + glPolyAmbientBufferID = 0; } - if (glFillSpecularBufferID != 0) { - pg.deleteVertexBufferObject(glFillSpecularBufferID, context.code()); - glFillSpecularBufferID = 0; + if (glPolySpecularBufferID != 0) { + pg.deleteVertexBufferObject(glPolySpecularBufferID, context.code()); + glPolySpecularBufferID = 0; } - if (glFillEmissiveBufferID != 0) { - pg.deleteVertexBufferObject(glFillEmissiveBufferID, context.code()); - glFillEmissiveBufferID = 0; + if (glPolyEmissiveBufferID != 0) { + pg.deleteVertexBufferObject(glPolyEmissiveBufferID, context.code()); + glPolyEmissiveBufferID = 0; } - if (glFillShininessBufferID != 0) { - pg.deleteVertexBufferObject(glFillShininessBufferID, context.code()); - glFillShininessBufferID = 0; + if (glPolyShininessBufferID != 0) { + pg.deleteVertexBufferObject(glPolyShininessBufferID, context.code()); + glPolyShininessBufferID = 0; } - if (glFillIndexBufferID != 0) { - pg.deleteVertexBufferObject(glFillIndexBufferID, context.code()); - glFillIndexBufferID = 0; + if (glPolyIndexBufferID != 0) { + pg.deleteVertexBufferObject(glPolyIndexBufferID, context.code()); + glPolyIndexBufferID = 0; } } @@ -3570,69 +3571,69 @@ public class PShapeOpenGL extends PShape { protected void updateGeometryImpl() { - if (modifiedFillVertices) { - int offset = firstModifiedFillVertex; - int size = lastModifiedFillVertex - offset + 1; - copyFillVertices(offset, size); - modifiedFillVertices = false; - firstModifiedFillVertex = PConstants.MAX_INT; - lastModifiedFillVertex = PConstants.MIN_INT; + if (modifiedPolyVertices) { + int offset = firstModifiedPolyVertex; + int size = lastModifiedPolyVertex - offset + 1; + copyPolyVertices(offset, size); + modifiedPolyVertices = false; + firstModifiedPolyVertex = PConstants.MAX_INT; + lastModifiedPolyVertex = PConstants.MIN_INT; } - if (modifiedFillColors) { - int offset = firstModifiedFillColor; - int size = lastModifiedFillColor - offset + 1; - copyFillColors(offset, size); - modifiedFillColors = false; - firstModifiedFillColor = PConstants.MAX_INT; - lastModifiedFillColor = PConstants.MIN_INT; + if (modifiedPolyColors) { + int offset = firstModifiedPolyColor; + int size = lastModifiedPolyColor - offset + 1; + copyPolyColors(offset, size); + modifiedPolyColors = false; + firstModifiedPolyColor = PConstants.MAX_INT; + lastModifiedPolyColor = PConstants.MIN_INT; } - if (modifiedFillNormals) { - int offset = firstModifiedFillNormal; - int size = lastModifiedFillNormal - offset + 1; - copyFillNormals(offset, size); - modifiedFillNormals = false; - firstModifiedFillNormal = PConstants.MAX_INT; - lastModifiedFillNormal = PConstants.MIN_INT; + if (modifiedPolyNormals) { + int offset = firstModifiedPolyNormal; + int size = lastModifiedPolyNormal - offset + 1; + copyPolyNormals(offset, size); + modifiedPolyNormals = false; + firstModifiedPolyNormal = PConstants.MAX_INT; + lastModifiedPolyNormal = PConstants.MIN_INT; } - if (modifiedFillTexCoords) { - int offset = firstModifiedFillTexCoord; - int size = lastModifiedFillTexCoord - offset + 1; - copyFillTexCoords(offset, size); - modifiedFillTexCoords = false; - firstModifiedFillTexCoord = PConstants.MAX_INT; - lastModifiedFillTexCoord = PConstants.MIN_INT; + if (modifiedPolyTexcoords) { + int offset = firstModifiedPolyTexcoord; + int size = lastModifiedPolyTexcoord - offset + 1; + copyPolyTexcoords(offset, size); + modifiedPolyTexcoords = false; + firstModifiedPolyTexcoord = PConstants.MAX_INT; + lastModifiedPolyTexcoord = PConstants.MIN_INT; } - if (modifiedFillAmbient) { - int offset = firstModifiedFillAmbient; - int size = lastModifiedFillAmbient - offset + 1; - copyFillAmbient(offset, size); - modifiedFillAmbient = false; - firstModifiedFillAmbient = PConstants.MAX_INT; - lastModifiedFillAmbient = PConstants.MIN_INT; + if (modifiedPolyAmbient) { + int offset = firstModifiedPolyAmbient; + int size = lastModifiedPolyAmbient - offset + 1; + copyPolyAmbient(offset, size); + modifiedPolyAmbient = false; + firstModifiedPolyAmbient = PConstants.MAX_INT; + lastModifiedPolyAmbient = PConstants.MIN_INT; } - if (modifiedFillSpecular) { - int offset = firstModifiedFillSpecular; - int size = lastModifiedFillSpecular - offset + 1; - copyFillSpecular(offset, size); - modifiedFillSpecular = false; - firstModifiedFillSpecular = PConstants.MAX_INT; - lastModifiedFillSpecular = PConstants.MIN_INT; + if (modifiedPolySpecular) { + int offset = firstModifiedPolySpecular; + int size = lastModifiedPolySpecular - offset + 1; + copyPolySpecular(offset, size); + modifiedPolySpecular = false; + firstModifiedPolySpecular = PConstants.MAX_INT; + lastModifiedPolySpecular = PConstants.MIN_INT; } - if (modifiedFillEmissive) { - int offset = firstModifiedFillEmissive; - int size = lastModifiedFillEmissive - offset + 1; - copyFillEmissive(offset, size); - modifiedFillEmissive = false; - firstModifiedFillEmissive = PConstants.MAX_INT; - lastModifiedFillEmissive = PConstants.MIN_INT; + if (modifiedPolyEmissive) { + int offset = firstModifiedPolyEmissive; + int size = lastModifiedPolyEmissive - offset + 1; + copyPolyEmissive(offset, size); + modifiedPolyEmissive = false; + firstModifiedPolyEmissive = PConstants.MAX_INT; + lastModifiedPolyEmissive = PConstants.MIN_INT; } - if (modifiedFillShininess) { - int offset = firstModifiedFillShininess; - int size = lastModifiedFillShininess - offset + 1; - copyFillShininess(offset, size); - modifiedFillShininess = false; - firstModifiedFillShininess = PConstants.MAX_INT; - lastModifiedFillShininess = PConstants.MIN_INT; + if (modifiedPolyShininess) { + int offset = firstModifiedPolyShininess; + int size = lastModifiedPolyShininess - offset + 1; + copyPolyShininess(offset, size); + modifiedPolyShininess = false; + firstModifiedPolyShininess = PConstants.MAX_INT; + lastModifiedPolyShininess = PConstants.MIN_INT; } if (modifiedLineVertices) { @@ -3689,66 +3690,66 @@ public class PShapeOpenGL extends PShape { } - protected void copyFillVertices(int offset, int size) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillVertexBufferID); + protected void copyPolyVertices(int offset, int size) { + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyVertexBufferID); pgl.glBufferSubData(PGL.GL_ARRAY_BUFFER, 4 * offset * PGL.SIZEOF_FLOAT, 4 * size * PGL.SIZEOF_FLOAT, - FloatBuffer.wrap(tessGeo.fillVertices, 0, 4 * size)); + FloatBuffer.wrap(tessGeo.polyVertices, 0, 4 * size)); pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); } - protected void copyFillColors(int offset, int size) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillColorBufferID); + protected void copyPolyColors(int offset, int size) { + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyColorBufferID); pgl.glBufferSubData(PGL.GL_ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, - IntBuffer.wrap(tessGeo.fillColors, 0, size)); + IntBuffer.wrap(tessGeo.polyColors, 0, size)); pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); } - protected void copyFillNormals(int offset, int size) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillNormalBufferID); + protected void copyPolyNormals(int offset, int size) { + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyNormalBufferID); pgl.glBufferSubData(PGL.GL_ARRAY_BUFFER, 3 * offset * PGL.SIZEOF_FLOAT, 3 * size * PGL.SIZEOF_FLOAT, - FloatBuffer.wrap(tessGeo.fillNormals, 0, 3 * size)); + FloatBuffer.wrap(tessGeo.polyNormals, 0, 3 * size)); pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); } - protected void copyFillTexCoords(int offset, int size) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillTexCoordBufferID); + protected void copyPolyTexcoords(int offset, int size) { + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyTexcoordBufferID); pgl.glBufferSubData(PGL.GL_ARRAY_BUFFER, 2 * offset * PGL.SIZEOF_FLOAT, 2 * size * PGL.SIZEOF_FLOAT, - FloatBuffer.wrap(tessGeo.fillTexcoords, 0, 2 * size)); + FloatBuffer.wrap(tessGeo.polyTexcoords, 0, 2 * size)); pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); } - protected void copyFillAmbient(int offset, int size) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillAmbientBufferID); + protected void copyPolyAmbient(int offset, int size) { + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyAmbientBufferID); pgl.glBufferSubData(PGL.GL_ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, - IntBuffer.wrap(tessGeo.fillAmbient, 0, size)); + IntBuffer.wrap(tessGeo.polyAmbient, 0, size)); pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); } - protected void copyFillSpecular(int offset, int size) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillSpecularBufferID); + protected void copyPolySpecular(int offset, int size) { + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolySpecularBufferID); pgl.glBufferSubData(PGL.GL_ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, - IntBuffer.wrap(tessGeo.fillSpecular, 0, size)); + IntBuffer.wrap(tessGeo.polySpecular, 0, size)); pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); } - protected void copyFillEmissive(int offset, int size) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillEmissiveBufferID); + protected void copyPolyEmissive(int offset, int size) { + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyEmissiveBufferID); pgl.glBufferSubData(PGL.GL_ARRAY_BUFFER, offset * PGL.SIZEOF_INT, size * PGL.SIZEOF_INT, - IntBuffer.wrap(tessGeo.fillEmissive, 0, size)); + IntBuffer.wrap(tessGeo.polyEmissive, 0, size)); pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); } - protected void copyFillShininess(int offset, int size) { - pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glFillShininessBufferID); + protected void copyPolyShininess(int offset, int size) { + pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, glPolyShininessBufferID); pgl.glBufferSubData(PGL.GL_ARRAY_BUFFER, offset * PGL.SIZEOF_FLOAT, size * PGL.SIZEOF_FLOAT, - FloatBuffer.wrap(tessGeo.fillShininess, 0, size)); + FloatBuffer.wrap(tessGeo.polyShininess, 0, size)); pgl.glBindBuffer(PGL.GL_ARRAY_BUFFER, 0); } @@ -3801,66 +3802,66 @@ public class PShapeOpenGL extends PShape { } - protected void setModifiedFillVertices(int first, int last) { - if (first < firstModifiedFillVertex) firstModifiedFillVertex = first; - if (last > lastModifiedFillVertex) lastModifiedFillVertex = last; - modifiedFillVertices = true; + protected void setModifiedPolyVertices(int first, int last) { + if (first < firstModifiedPolyVertex) firstModifiedPolyVertex = first; + if (last > lastModifiedPolyVertex) lastModifiedPolyVertex = last; + modifiedPolyVertices = true; modified = true; } - protected void setModifiedFillColors(int first, int last) { - if (first < firstModifiedFillColor) firstModifiedFillColor = first; - if (last > lastModifiedFillColor) lastModifiedFillColor = last; - modifiedFillColors = true; + protected void setModifiedPolyColors(int first, int last) { + if (first < firstModifiedPolyColor) firstModifiedPolyColor = first; + if (last > lastModifiedPolyColor) lastModifiedPolyColor = last; + modifiedPolyColors = true; modified = true; } - protected void setModifiedFillNormals(int first, int last) { - if (first < firstModifiedFillNormal) firstModifiedFillNormal = first; - if (last > lastModifiedFillNormal) lastModifiedFillNormal = last; - modifiedFillNormals = true; + protected void setModifiedPolyNormals(int first, int last) { + if (first < firstModifiedPolyNormal) firstModifiedPolyNormal = first; + if (last > lastModifiedPolyNormal) lastModifiedPolyNormal = last; + modifiedPolyNormals = true; modified = true; } - protected void setModifiedFillTexcoords(int first, int last) { - if (first < firstModifiedFillTexCoord) firstModifiedFillTexCoord = first; - if (last > lastModifiedFillTexCoord) lastModifiedFillTexCoord = last; - modifiedFillTexCoords = true; + protected void setModifiedPolyTexcoords(int first, int last) { + if (first < firstModifiedPolyTexcoord) firstModifiedPolyTexcoord = first; + if (last > lastModifiedPolyTexcoord) lastModifiedPolyTexcoord = last; + modifiedPolyTexcoords = true; modified = true; } - protected void setModifiedFillAmbient(int first, int last) { - if (first < firstModifiedFillAmbient) firstModifiedFillAmbient = first; - if (last > lastModifiedFillAmbient) lastModifiedFillAmbient = last; - modifiedFillAmbient = true; + protected void setModifiedPolyAmbient(int first, int last) { + if (first < firstModifiedPolyAmbient) firstModifiedPolyAmbient = first; + if (last > lastModifiedPolyAmbient) lastModifiedPolyAmbient = last; + modifiedPolyAmbient = true; modified = true; } - protected void setModifiedFillSpecular(int first, int last) { - if (first < firstModifiedFillSpecular) firstModifiedFillSpecular = first; - if (last > lastModifiedFillSpecular) lastModifiedFillSpecular = last; - modifiedFillSpecular = true; + protected void setModifiedPolySpecular(int first, int last) { + if (first < firstModifiedPolySpecular) firstModifiedPolySpecular = first; + if (last > lastModifiedPolySpecular) lastModifiedPolySpecular = last; + modifiedPolySpecular = true; modified = true; } - protected void setModifiedFillEmissive(int first, int last) { - if (first < firstModifiedFillEmissive) firstModifiedFillEmissive = first; - if (last > lastModifiedFillEmissive) lastModifiedFillEmissive = last; - modifiedFillEmissive = true; + protected void setModifiedPolyEmissive(int first, int last) { + if (first < firstModifiedPolyEmissive) firstModifiedPolyEmissive = first; + if (last > lastModifiedPolyEmissive) lastModifiedPolyEmissive = last; + modifiedPolyEmissive = true; modified = true; } - protected void setModifiedFillShininess(int first, int last) { - if (first < firstModifiedFillShininess) firstModifiedFillShininess = first; - if (last > lastModifiedFillShininess) lastModifiedFillShininess = last; - modifiedFillShininess = true; + protected void setModifiedPolyShininess(int first, int last) { + if (first < firstModifiedPolyShininess) firstModifiedPolyShininess = first; + if (last > lastModifiedPolyShininess) lastModifiedPolyShininess = last; + modifiedPolyShininess = true; modified = true; } @@ -4016,10 +4017,10 @@ public class PShapeOpenGL extends PShape { return; } - if (haveFill) { - renderFill(g, texture); + if (havePolys) { + renderPolys(g, texture); if (g.haveRaw()) { - rawFill(g, texture); + rawPolys(g, texture); } } @@ -4211,7 +4212,7 @@ public class PShapeOpenGL extends PShape { } - protected void renderFill(PGraphicsOpenGL g, PImage textureImage) { + protected void renderPolys(PGraphicsOpenGL g, PImage textureImage) { PTexture tex = null; if (textureImage != null) { tex = g.getTexture(textureImage); @@ -4221,32 +4222,32 @@ public class PShapeOpenGL extends PShape { } } - FillShader shader = g.getFillShader(g.lights, tex != null); + PolyShader shader = g.getPolyShader(g.lights, tex != null); shader.start(); - IndexCache cache = tessGeo.fillIndexCache; - for (int n = firstFillIndexCache; n <= lastFillIndexCache; n++) { + IndexCache cache = tessGeo.polyIndexCache; + for (int n = firstPolyIndexCache; n <= lastpolyIndexCache; n++) { int ioffset = cache.indexOffset[n]; int icount = cache.indexCount[n]; int voffset = cache.vertexOffset[n]; - shader.setVertexAttribute(root.glFillVertexBufferID, 4, PGL.GL_FLOAT, 0, 4 * voffset * PGL.SIZEOF_FLOAT); - shader.setColorAttribute(root.glFillColorBufferID, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); + shader.setVertexAttribute(root.glPolyVertexBufferID, 4, PGL.GL_FLOAT, 0, 4 * voffset * PGL.SIZEOF_FLOAT); + shader.setColorAttribute(root.glPolyColorBufferID, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); if (g.lights) { - shader.setNormalAttribute(root.glFillNormalBufferID, 3, PGL.GL_FLOAT, 0, 3 * voffset * PGL.SIZEOF_FLOAT); - shader.setAmbientAttribute(root.glFillAmbientBufferID, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); - shader.setSpecularAttribute(root.glFillSpecularBufferID, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); - shader.setEmissiveAttribute(root.glFillEmissiveBufferID, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); - shader.setShininessAttribute(root.glFillShininessBufferID, 1, PGL.GL_FLOAT, 0, voffset * PGL.SIZEOF_FLOAT); + shader.setNormalAttribute(root.glPolyNormalBufferID, 3, PGL.GL_FLOAT, 0, 3 * voffset * PGL.SIZEOF_FLOAT); + shader.setAmbientAttribute(root.glPolyAmbientBufferID, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); + shader.setSpecularAttribute(root.glPolySpecularBufferID, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); + shader.setEmissiveAttribute(root.glPolyEmissiveBufferID, 4, PGL.GL_UNSIGNED_BYTE, 0, 4 * voffset * PGL.SIZEOF_BYTE); + shader.setShininessAttribute(root.glPolyShininessBufferID, 1, PGL.GL_FLOAT, 0, voffset * PGL.SIZEOF_FLOAT); } if (tex != null) { - shader.setTexCoordAttribute(root.glFillTexCoordBufferID, 2, PGL.GL_FLOAT, 0, 2 * voffset * PGL.SIZEOF_FLOAT); + shader.setTexcoordAttribute(root.glPolyTexcoordBufferID, 2, PGL.GL_FLOAT, 0, 2 * voffset * PGL.SIZEOF_FLOAT); shader.setTexture(tex); } - pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, root.glFillIndexBufferID); + pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, root.glPolyIndexBufferID); pgl.glDrawElements(PGL.GL_TRIANGLES, icount, PGL.INDEX_TYPE, ioffset * PGL.SIZEOF_INDEX); pgl.glBindBuffer(PGL.GL_ELEMENT_ARRAY_BUFFER, 0); } @@ -4259,20 +4260,21 @@ public class PShapeOpenGL extends PShape { } } - protected void rawFill(PGraphicsOpenGL g, PImage textureImage) { + + protected void rawPolys(PGraphicsOpenGL g, PImage textureImage) { PGraphics raw = g.getRaw(); raw.colorMode(RGB); raw.noStroke(); raw.beginShape(TRIANGLES); - float[] vertices = tessGeo.fillVertices; - int[] color = tessGeo.fillColors; - float[] uv = tessGeo.fillTexcoords; - short[] indices = tessGeo.fillIndices; + float[] vertices = tessGeo.polyVertices; + int[] color = tessGeo.polyColors; + float[] uv = tessGeo.polyTexcoords; + short[] indices = tessGeo.polyIndices; - IndexCache cache = tessGeo.fillIndexCache; - for (int n = firstFillIndexCache; n <= lastFillIndexCache; n++) { + IndexCache cache = tessGeo.polyIndexCache; + for (int n = firstPolyIndexCache; n <= lastpolyIndexCache; n++) { int ioffset = cache.indexOffset[n]; int icount = cache.indexCount[n]; int voffset = cache.vertexOffset[n]; diff --git a/java/libraries/opengl/src/processing/opengl/PTexture.java b/java/libraries/opengl/src/processing/opengl/PTexture.java index a6ac6ffe5..3ebe2d822 100644 --- a/java/libraries/opengl/src/processing/opengl/PTexture.java +++ b/java/libraries/opengl/src/processing/opengl/PTexture.java @@ -3,12 +3,12 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2011 Andres Colubri - Copyright (c) 2010 Ben Fry and Casey Reas + Copyright (c) 2011-12 Ben Fry and Casey Reas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public - License version 2.1 as published by the Free Software Foundation. + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -58,8 +58,8 @@ public class PTexture implements PConstants { public int glHeight; protected boolean usingMipmaps; - protected float maxTexCoordU; - protected float maxTexCoordV; + protected float maxTexcoordU; + protected float maxTexcoordV; protected boolean flippedX; protected boolean flippedY; @@ -346,8 +346,8 @@ public class PTexture implements PConstants { * Returns the maximum possible value for the texture coordinate U (horizontal). * @return float */ - public float getMaxTexCoordU() { - return maxTexCoordU; + public float getMaxU() { + return maxTexcoordU; } @@ -355,8 +355,8 @@ public class PTexture implements PConstants { * Returns the maximum possible value for the texture coordinate V (vertical). * @return float */ - public float getMaxTexCoordV() { - return maxTexCoordV; + public float getMaxV() { + return maxTexcoordV; } @@ -742,8 +742,8 @@ public class PTexture implements PConstants { // is non-power-of-two, then glWidth (glHeight) will be greater than w (h) because it // is chosen to be the next power of two, and this quotient will give the appropriate // maximum texture coordinate value given this situation. - maxTexCoordU = (float)width / glWidth; - maxTexCoordV = (float)height / glHeight; + maxTexcoordU = (float)width / glWidth; + maxTexcoordV = (float)height / glHeight; } @@ -877,8 +877,8 @@ public class PTexture implements PConstants { glHeight = src.glHeight; usingMipmaps = src.usingMipmaps; - maxTexCoordU = src.maxTexCoordU; - maxTexCoordV = src.maxTexCoordV; + maxTexcoordU = src.maxTexcoordU; + maxTexcoordV = src.maxTexcoordV; flippedX = src.flippedX; flippedY = src.flippedY; diff --git a/java/libraries/opengl/src/processing/opengl/PointShaderFrag.glsl b/java/libraries/opengl/src/processing/opengl/PointShaderFrag.glsl index 8c22a6ac5..f2b8e511a 100644 --- a/java/libraries/opengl/src/processing/opengl/PointShaderFrag.glsl +++ b/java/libraries/opengl/src/processing/opengl/PointShaderFrag.glsl @@ -1,12 +1,11 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2011 Andres Colubri + Copyright (c) 20011-12 Ben Fry and Casey Reas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + License version 2.1 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -17,7 +16,7 @@ Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + */ #ifdef GL_ES precision mediump float; diff --git a/java/libraries/opengl/src/processing/opengl/PointShaderVert.glsl b/java/libraries/opengl/src/processing/opengl/PointShaderVert.glsl index 9e2195306..302b777e7 100644 --- a/java/libraries/opengl/src/processing/opengl/PointShaderVert.glsl +++ b/java/libraries/opengl/src/processing/opengl/PointShaderVert.glsl @@ -1,12 +1,11 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2011 Andres Colubri + Copyright (c) 20011-12 Ben Fry and Casey Reas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + License version 2.1 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -17,7 +16,7 @@ Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + */ uniform mat4 projectionMatrix; uniform mat4 modelviewMatrix; diff --git a/java/libraries/opengl/src/processing/opengl/FillShaderFragNoTex.glsl b/java/libraries/opengl/src/processing/opengl/PolyShaderFragNoTex.glsl similarity index 82% rename from java/libraries/opengl/src/processing/opengl/FillShaderFragNoTex.glsl rename to java/libraries/opengl/src/processing/opengl/PolyShaderFragNoTex.glsl index 8c22a6ac5..f2b8e511a 100644 --- a/java/libraries/opengl/src/processing/opengl/FillShaderFragNoTex.glsl +++ b/java/libraries/opengl/src/processing/opengl/PolyShaderFragNoTex.glsl @@ -1,12 +1,11 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2011 Andres Colubri + Copyright (c) 20011-12 Ben Fry and Casey Reas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + License version 2.1 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -17,7 +16,7 @@ Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + */ #ifdef GL_ES precision mediump float; diff --git a/java/libraries/opengl/src/processing/opengl/FillShaderVertFull.glsl b/java/libraries/opengl/src/processing/opengl/PolyShaderVertFull.glsl similarity index 96% rename from java/libraries/opengl/src/processing/opengl/FillShaderVertFull.glsl rename to java/libraries/opengl/src/processing/opengl/PolyShaderVertFull.glsl index 42fba0556..9bb7e3515 100644 --- a/java/libraries/opengl/src/processing/opengl/FillShaderVertFull.glsl +++ b/java/libraries/opengl/src/processing/opengl/PolyShaderVertFull.glsl @@ -1,12 +1,11 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2011 Andres Colubri + Copyright (c) 20011-12 Ben Fry and Casey Reas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + License version 2.1 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -17,7 +16,7 @@ Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + */ uniform mat4 modelviewMatrix; uniform mat4 projmodelviewMatrix; diff --git a/java/libraries/opengl/src/processing/opengl/FillShaderVertLit.glsl b/java/libraries/opengl/src/processing/opengl/PolyShaderVertLit.glsl similarity index 96% rename from java/libraries/opengl/src/processing/opengl/FillShaderVertLit.glsl rename to java/libraries/opengl/src/processing/opengl/PolyShaderVertLit.glsl index 6fd2f0ecf..7a6ce42b5 100644 --- a/java/libraries/opengl/src/processing/opengl/FillShaderVertLit.glsl +++ b/java/libraries/opengl/src/processing/opengl/PolyShaderVertLit.glsl @@ -1,12 +1,11 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2011 Andres Colubri + Copyright (c) 20011-12 Ben Fry and Casey Reas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + License version 2.1 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -17,7 +16,7 @@ Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + */ uniform mat4 modelviewMatrix; uniform mat4 projmodelviewMatrix; diff --git a/java/libraries/opengl/src/processing/opengl/FillShaderVertSimple.glsl b/java/libraries/opengl/src/processing/opengl/PolyShaderVertSimple.glsl similarity index 83% rename from java/libraries/opengl/src/processing/opengl/FillShaderVertSimple.glsl rename to java/libraries/opengl/src/processing/opengl/PolyShaderVertSimple.glsl index 9dd5d2b07..a8e423962 100644 --- a/java/libraries/opengl/src/processing/opengl/FillShaderVertSimple.glsl +++ b/java/libraries/opengl/src/processing/opengl/PolyShaderVertSimple.glsl @@ -1,12 +1,11 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2011 Andres Colubri + Copyright (c) 20011-12 Ben Fry and Casey Reas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + License version 2.1 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -17,7 +16,7 @@ Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + */ uniform mat4 projmodelviewMatrix; diff --git a/java/libraries/opengl/src/processing/opengl/FillShaderVertTex.glsl b/java/libraries/opengl/src/processing/opengl/PolyShaderVertTex.glsl similarity index 85% rename from java/libraries/opengl/src/processing/opengl/FillShaderVertTex.glsl rename to java/libraries/opengl/src/processing/opengl/PolyShaderVertTex.glsl index 233422d87..99d595d87 100644 --- a/java/libraries/opengl/src/processing/opengl/FillShaderVertTex.glsl +++ b/java/libraries/opengl/src/processing/opengl/PolyShaderVertTex.glsl @@ -1,12 +1,11 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2011 Andres Colubri + Copyright (c) 20011-12 Ben Fry and Casey Reas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + License version 2.1 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -17,7 +16,7 @@ Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + */ uniform mat4 projmodelviewMatrix; uniform mat4 texcoordMatrix; diff --git a/java/libraries/opengl/src/processing/opengl/FillShaderFragTex.glsl b/java/libraries/opengl/src/processing/opengl/PolylShaderFragTex.glsl similarity index 84% rename from java/libraries/opengl/src/processing/opengl/FillShaderFragTex.glsl rename to java/libraries/opengl/src/processing/opengl/PolylShaderFragTex.glsl index d20d96d2a..b8970f49d 100644 --- a/java/libraries/opengl/src/processing/opengl/FillShaderFragTex.glsl +++ b/java/libraries/opengl/src/processing/opengl/PolylShaderFragTex.glsl @@ -1,12 +1,11 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2011 Andres Colubri + Copyright (c) 20011-12 Ben Fry and Casey Reas This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + License version 2.1 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -17,7 +16,7 @@ Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + */ #ifdef GL_ES precision mediump float;