Question about PShapes

edited September 2016 in Questions about Code

I was learning about using PShapes for a project I'm working on and I found a strange issue. I was looking at the PShape examples specifically this one with a triangle strip:

PShape s;

void setup() {
  size(100, 100, P2D);
  s = createShape();
  s.beginShape(TRIANGLE_STRIP);
  s.vertex(30, 75);
  s.vertex(40, 20);
  s.vertex(50, 75);
  s.vertex(60, 20);
  s.vertex(70, 75);
  s.vertex(80, 20);
  s.vertex(90, 75);
  s.endShape();
}

void draw() {
  shape(s, 0, 0);
}

It seems fairly straightforward so I implemented some similar code into my program. The triangle strip shape I made did not behave properly as the lines did not connect to the vertices correctly. I puzzled over this for a half hour as I was doing nearly the exact same thing as the above example. I realized the only difference was my rendering mode was default while the example's was P2D. This difference is obvious if you run the above code with and without the P2D specification.

Why is this the case? Is this an intentional difference between the renders? It seems totally bizarre.

Tagged:

Answers

Sign In or Register to comment.