Skip to content

Android Mode PShape Vertex Default Renderer Error #701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spacemanstan opened this issue Jul 18, 2022 · 1 comment
Closed

Android Mode PShape Vertex Default Renderer Error #701

spacemanstan opened this issue Jul 18, 2022 · 1 comment

Comments

@spacemanstan
Copy link

I believe the default renderer in Android mode has a bug affecting PShapes drawn using vertices.

The issue only seems to occur when trying to declare a PShape object, and drawing to that object using vertices. The error can be bypassed by drawing the shape in the main Draw() loop repeatedly, however I believe that removes the advantage of using a PShape. The error message (partially) thrown is

FATAL EXCEPTION: Animation Thread
Process: processing.test.pshapetest, PID: 4730
java.lang.ArrayIndexOutOfBoundsException: src.length=2 srcPos=0 dst.length=37 dstPos=0 length=37
at java.lang.System.arraycopy(Native Method)
at processing.core.PGraphics.vertex(PGraphics.java:1427)

However if you change the renderer to P2D the error vanishes. I didn't paste the entire error but what stood out to me, which is the arraycopy and vertex messages. I tried drawing the shapes in many different ways but P2D appears the only way to draw vertex shapes so far from my small amount of experimenting.

This code will throw the error message I quoted above:

PShape test;
float dim;
PVector testPos;

void setup() {
  fullScreen();
  orientation(PORTRAIT);
    
  dim = width/10;
  testPos = new PVector(width/2, height*2/3);
  
  test = createShape();
  
  test.beginShape();
  
  test.noStroke();
  test.fill(255);
  
  test.vertex(0, -2*dim);
  test.vertex(-dim, dim);
  test.vertex(dim, dim);
  
  test.endShape(CLOSE);
}

void draw() {
  background(0);
  
  pushMatrix();
  
  translate(testPos.x, testPos.y);
  
  shape(test);
  
  popMatrix();
}

but if you change fullScreen(); to fullScreen(P2D); it will compile and run fine.

I made a reddit post about it and tried running the code that was suggested in a thread I was linked to in the reddit post I made and had similar results.

I think this may be a bug with the default renderer.

@codeanticode
Copy link
Contributor

@spacemanstan thanks for posting this issue, I can confirm that affects the default renderer only on Android, not in the Java mode. I will look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants