P3D hint() with 2D depth sort not working

Hello i want to create layer system and i cant ENABLE_DEPTH_SORT in a hint…
Its resizing… yeah one of two objects gets before and after when i moving mouse, but i want to make it without sizing… :confused: can you help me ?

void setup() {
  size(500, 500, P3D);

  ((PGraphicsOpenGL)g).textureSampling(3);
  hint(ENABLE_DEPTH_SORT);
}

void draw() {
  background(0);

  pushMatrix();
  translate(0, 0, 100);
  fill(255, 0, 0);
  rect(100, 100, 200, 300);
  popMatrix();

  pushMatrix();
  translate(0, 0, mouseX);
  fill(0, 255, 0);
  rect(200, 100, 200, 300);
  popMatrix();
}
1 Like

Just want to set ortho :smiley: :slight_smile:

Standart basic ortho:

ortho(-width/2, width/2, -height/2, height/2);

here is the one line change, wich working as i want :smiley:

void setup() {
  size(500, 500, P3D);

  ((PGraphicsOpenGL)g).textureSampling(3);
  hint(ENABLE_DEPTH_SORT);
  ortho(-width/2, width/2, -height/2, height/2);
}

void draw() {
  background(0);

  pushMatrix();
  translate(0, 0, 100);
  fill(255, 0, 0);
  rect(100, 100, 200, 300);
  popMatrix();

  pushMatrix();
  translate(0, 0, mouseX);
  fill(0, 255, 0);
  rect(200, 100, 200, 300);
  popMatrix();
}
2 Likes