diff --git a/core/src/processing/opengl/PGraphicsOpenGL.java b/core/src/processing/opengl/PGraphicsOpenGL.java index 05ccfdfb2..b54ee54a8 100644 --- a/core/src/processing/opengl/PGraphicsOpenGL.java +++ b/core/src/processing/opengl/PGraphicsOpenGL.java @@ -2589,7 +2589,7 @@ public class PGraphicsOpenGL extends PGraphics { attrib.updateLoc(shader); shader.setAttributeVBO(attrib.glLoc, attrib.glName, attrib.size, attrib.type, - false, 0, attrib.sizeInBytes(voffset)); + attrib.isColor(), 0, attrib.sizeInBytes(voffset)); } shader.draw(glPolyIndex, icount, ioffset); @@ -7015,12 +7015,13 @@ public class PGraphicsOpenGL extends PGraphics { static protected class VertexAttribute { - static final int POSITIONAL = 0; - static final int NORMAL = 1; - static final int OTHER = 2; + static final int POSITION = 0; + static final int NORMAL = 1; + static final int COLOR = 2; + static final int OTHER = 3; String name; - int kind; // POSITIONAL, NORMAL, OTHER + int kind; // POSITION, NORMAL, COLOR, OTHER int type; // GL_INT, GL_FLOAT, GL_BOOL int size; // number of elements (1, 2, 3, or 4) int elementSize; @@ -7037,9 +7038,11 @@ public class PGraphicsOpenGL extends PGraphics { this.size = size; if (name.indexOf("pos") == 0) { - kind = POSITIONAL; + kind = POSITION; } else if (name.indexOf("norm") == 0) { kind = NORMAL; + } else if (name.indexOf("color") == 0 && type == PGL.INT && size == 1) { + kind = COLOR; } else { kind = OTHER; } @@ -7059,6 +7062,22 @@ public class PGraphicsOpenGL extends PGraphics { glLoc = -1; } + boolean isPosition() { + return kind == POSITION; + } + + boolean isNormal() { + return kind == NORMAL; + } + + boolean isColor() { + return kind == COLOR; + } + + boolean isOther() { + return kind == OTHER; + } + boolean bufferCreated() { return 0 < glName; } @@ -8799,7 +8818,7 @@ public class PGraphicsOpenGL extends PGraphics { FloatBuffer polyShininessBuffer; // Generic attributes - HashMap attribBuffers; + HashMap attribBuffers = new HashMap(); int polyIndexCount; int firstPolyIndex;