I’ve been devaloping a mobile game for a while using Processing. While optimising, I discovered a weird problem with PShape rendeing on Android. PShapes created and saved as a variable draw behind everything, whereas ones made on the fly draw correctly. The only way I’ve found to fix this is with resetShader(), but that seems to be a fairly expensive method call, from my testing. Anything know a solution to this?
PShape s; void setup() { s = createShape(); s.beginShape(); s.fill(102); s.vertex(0, 0); s.vertex(200, 0); s.vertex(200, 200); s.vertex(0, 200); s.endShape(CLOSE); } void draw() { translate(width / 2, height / 2); background(150); fill(255); rect(-400, -400, 800, 800); // broken shape translate(-300, 350); //resetShader(); // the broken shape works if this, resetShader(), is called before it // but that only if done after the previous draw call (i.e. rect() above). shape(s); // working shape translate(400, 0); beginShape(); fill(102); vertex(0, 0); // top left vertex(200, 0); // top right vertex(200, 200); // bottom right vertex(0, 200); // bottom left endShape(); }