Ok, thanks to your examples I made version 2
Main change is subtle but important: show spheres. With spheres performance and sorting issues are much more obvious.
class Hint {
private int y;
private String name;
private boolean active;
private int ON_CONST;
private int OFF_CONST;
Hint(int y, String name, boolean active, int ON, int OFF) {
this.y = y;
this.name = name;
this.active = active;
this.ON_CONST = ON;
this.OFF_CONST = OFF;
call_hint();
}
void toggle() {
active = !active;
}
void call_hint() {
hint(active ? ON_CONST : OFF_CONST);
}
void draw() {
text(name + " " + active, 20, y);
}
void mousePressed() {
if (mouseY > y - 15 && mouseY < y + 5) {
toggle();
call_hint();
}
}
}
Hint[] hints;
boolean useSphere;
void setup() {
size(800, 600, P3D);
hints = new Hint[] {
new Hint(40, "DEPTH_TEST", false, ENABLE_DEPTH_TEST, DISABLE_DEPTH_TEST),
new Hint(60, "DEPTH_SORT", false, ENABLE_DEPTH_SORT, DISABLE_DEPTH_SORT),
new Hint(80, "DEPTH_MASK", false, ENABLE_DEPTH_MASK, DISABLE_DEPTH_MASK),
new Hint(100, "OPTIMIZED_STROKE", true, ENABLE_OPTIMIZED_STROKE, DISABLE_OPTIMIZED_STROKE),
new Hint(120, "STROKE_PERSPECTIVE", false, ENABLE_STROKE_PERSPECTIVE, DISABLE_STROKE_PERSPECTIVE)
};
}
void draw() {
background(255);
fill(0);
for (Hint h : hints) {
h.draw();
}
text("<- use the mouse to toggle settings", 200, 40);
text("click here to toggle shape", 300, 580);
fill(255, 40, 20, 100);
translate(width/2, height/2);
rotateY(frameCount * 0.005);
for (int x = -200; x<=200; x+=200) {
for (int y = -200; y<=200; y+=200) {
pushMatrix();
translate(x, 0, y);
if (useSphere) {
sphere(90);
} else {
box(180);
}
popMatrix();
}
}
}
void mousePressed() {
if (mouseY > 150) {
useSphere = !useSphere;
} else {
for (Hint h : hints) {
h.mousePressed();
}
}
}