Closed mheesakkers closed 1 year ago
Which version of PGS are you using? PGS 1.2.0+ behaves well with P2D. In fact I've just tried the slice example in P2D
with the newest version and that's working fine.
In 1.2.0, output PShapes are now always created with a shape family of PATH (rather than GEOMETRY) to maximise compatibility with the P2D renderer.
I'm running 1.2.0 but the problem only exists when you create a PShape with createShape(). Then a PShapeOpenGL is created it seems. And that PShapeOpenGL throws a null pointer in the slice method. The slice example works due to the PGS creation of a shape.
Can you share code?
This works in P2D for me:
var circle = createShape(ELLIPSE, width / 2, height / 2, 500, 500);
shape(PGS_Processing.slice(circle, new PVector(0, 0), new PVector(width, height)));
Sure! Sorry took a while. But the difference lays in the way I create a PShape - I use createShape() with beginShape() and endShape(). The code below throws an error when you use the P2D renderer.
import micycle.pgs.*;
size(512, 512, P2D); // Remove P2D renderer and it works
PShape shape = createShape();
shape.beginShape();
for (int i = 0; i < 4; i++) {
float angle = TWO_PI / 4 * i;
float radius = 128;
float x = width * 0.5 + sin(angle) * radius;
float y = height * 0.5 + cos(angle) * radius;
shape.vertex(x, y);
}
shape.endShape(CLOSE);
PShape slices = PGS_Processing.slice(shape, new PVector(0, 0), new PVector(width, height));
PGS_Conversion.setAllFillColor(slices, #333333);
PGS_Conversion.setAllStrokeColor(slices, #00ffff, 4);
shape(slices);
Not sure if this is an issue, but I ran into a nullpointer exception when I was trying to slice a custom PShape using the P2D renderer. PShapes created in this renderer are for some reason of the type PShapeOpenGL which I think PGS can't handle, right?. Leaving the renderer option blank results in no errors.