use of processing.opengl.PGraphicsOpenGL.VertexAttribute in project processing by processing.
the class PShapeOpenGL method contextIsOutdated.
protected boolean contextIsOutdated() {
boolean outdated = !pgl.contextIsCurrent(context);
if (outdated) {
bufPolyVertex.dispose();
bufPolyColor.dispose();
bufPolyNormal.dispose();
bufPolyTexcoord.dispose();
bufPolyAmbient.dispose();
bufPolySpecular.dispose();
bufPolyEmissive.dispose();
bufPolyShininess.dispose();
for (VertexAttribute attrib : polyAttribs.values()) {
attrib.buf.dispose();
}
bufPolyIndex.dispose();
bufLineVertex.dispose();
bufLineColor.dispose();
bufLineAttrib.dispose();
bufLineIndex.dispose();
bufPointVertex.dispose();
bufPointColor.dispose();
bufPointAttrib.dispose();
bufPointIndex.dispose();
}
return outdated;
}
use of processing.opengl.PGraphicsOpenGL.VertexAttribute in project processing by processing.
the class PShapeOpenGL method setAttrib.
@Override
public void setAttrib(String name, int index, boolean... values) {
if (openShape) {
PGraphics.showWarning(INSIDE_BEGIN_END_ERROR, "setNormal()");
return;
}
VertexAttribute attrib = polyAttribs.get(name);
byte[] array = inGeo.battribs.get(name);
for (int i = 0; i < values.length; i++) {
array[attrib.size * index + 0] = (byte) (values[i] ? 1 : 0);
}
markForTessellation();
}
use of processing.opengl.PGraphicsOpenGL.VertexAttribute in project processing by processing.
the class PShapeOpenGL method tessellate.
protected void tessellate() {
if (root == this && parent == null) {
// Root shape
if (polyAttribs == null) {
polyAttribs = PGraphicsOpenGL.newAttributeMap();
collectPolyAttribs();
}
if (tessGeo == null) {
tessGeo = PGraphicsOpenGL.newTessGeometry(pg, polyAttribs, PGraphicsOpenGL.RETAINED);
}
tessGeo.clear();
for (int i = 0; i < polyAttribs.size(); i++) {
VertexAttribute attrib = polyAttribs.get(i);
tessGeo.initAttrib(attrib);
}
tessellateImpl();
// Tessellated arrays are trimmed since they are expanded
// by doubling their old size, which might lead to arrays
// larger than the vertex counts.
tessGeo.trim();
}
}
use of processing.opengl.PGraphicsOpenGL.VertexAttribute in project processing by processing.
the class PShapeOpenGL method collectPolyAttribs.
protected void collectPolyAttribs() {
AttributeMap rootAttribs = root.polyAttribs;
if (family == GROUP) {
for (int i = 0; i < childCount; i++) {
PShapeOpenGL child = (PShapeOpenGL) children[i];
child.collectPolyAttribs();
}
} else {
for (int i = 0; i < polyAttribs.size(); i++) {
VertexAttribute attrib = polyAttribs.get(i);
tessGeo.initAttrib(attrib);
if (rootAttribs.containsKey(attrib.name)) {
VertexAttribute rattrib = rootAttribs.get(attrib.name);
if (rattrib.diff(attrib)) {
throw new RuntimeException("Children shapes cannot have different attributes with same name");
}
} else {
rootAttribs.put(attrib.name, attrib);
}
}
}
}
use of processing.opengl.PGraphicsOpenGL.VertexAttribute in project processing by processing.
the class PShapeOpenGL method setAttrib.
@Override
public void setAttrib(String name, int index, float... values) {
if (openShape) {
PGraphics.showWarning(INSIDE_BEGIN_END_ERROR, "setNormal()");
return;
}
VertexAttribute attrib = polyAttribs.get(name);
float[] array = inGeo.fattribs.get(name);
for (int i = 0; i < values.length; i++) {
array[attrib.size * index + 0] = values[i];
}
markForTessellation();
}
Aggregations