Depth Sorting and PShape


#1

Am I doing something wrong or hint(ENABLE_DEPTH_SORT); only works with beginShape() and endShape() and not with PShape. If I am not wrong, and this is a issue, how can I do depth sort myself on PShapes ?

Screenshot, red = PShape, blue = not PShape like : beginShape(), box(), line() …

The code, using QueasyCam library :

import queasycam.*;

QueasyCam cam;

PShape box;
PShape sphere;

public void setup() {
  fullScreen(P3D);
  
  cam = new QueasyCam(this);
  
  box = createShape(BOX, 100.0f);
  sphere = createShape(SPHERE, 50.0f);
  
  box.setStroke(false);
  box.setFill(color(255, 0, 0, 100));
  
  sphere.setStroke(false);
  sphere.setFill(color(255, 0, 0, 100));
}

public void draw() {
  background(255);
  
  // Just to be sure
  hint(ENABLE_DEPTH_TEST);
  hint(ENABLE_DEPTH_MASK);
  
  // Magic line that should all correct
  hint(ENABLE_DEPTH_SORT);
  
  shape(box);
  
  pushMatrix();
  translate(0, 0, 200);
  shape(sphere);
  popMatrix();
  
  pushMatrix();
  translate(200, 0, 0);
  noStroke();
  fill(0, 0, 255, 100);
  box(100);
  popMatrix();
  
  pushMatrix();
  translate(200, 0, 200);
  noStroke();
  fill(0, 0, 255, 100);
  sphere(50);
  popMatrix();
}

Also, weird lag when going in between the 4 shapes, dont know why.

Thank you !