Skip to content

Vertex ordering for beginShape(QUADS) is different in WebGL from 2D mode #5770

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
1 of 17 tasks
davepagurek opened this issue Aug 28, 2022 · 0 comments · Fixed by #5771
Closed
1 of 17 tasks

Vertex ordering for beginShape(QUADS) is different in WebGL from 2D mode #5770

davepagurek opened this issue Aug 28, 2022 · 0 comments · Fixed by #5771
Assignees

Comments

@davepagurek
Copy link
Contributor

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build Process
  • Unit Testing
  • Internalization
  • Friendly Errors
  • Other (specify if possible)

p5.js version

Commit c9fb107 on main

Web browser and version

Firefox 103.0.2

Operating System

MacOS

Steps to reproduce this

Steps:

Quads rendered with beginShape(QUADS) that look like rectangles in 2D mode end up with self-intersections in WebGL mode. This is because it currently treats the vertex ordering the same way QUAD_STRIP does, which does one side after the other in the same order, rather than going around one quad in a consistent CW or CCW direction.

Snippet:

With the following code:

function setup() {
  createCanvas(256, 256, WEBGL);
}
function draw() {
  background(240);
  stroke(0);
  fill(255, 0, 0)
  beginShape(QUADS);
  vertex(-25, -25, 0);
  vertex(25, -25, 0);
  vertex(25, 25, 0);
  vertex(-25, 25, 0);
  endShape(CLOSE);
}

the resulting shape looks different when you change the environment:

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

Successfully merging a pull request may close this issue.

1 participant