if one shape is drawn only once, in front of another shape that is drawn every cycle, and there is no background, the shape in front is never drawn over.
easiest explained with this code:
Code:
PGraphics3 g3;
int numPx;
boolean clearit = false;
boolean firstframe = true;
boolean secondframe = false;
void setup () {
size(400, 400, P3D);
numPx = width*height;
g3 = (PGraphics3) g;
noStroke();
}
void draw () {
//g3.zbuffer = new float[numPx];
if (secondframe) {
translate(0, 0, 150);
fill(0, 255, 0);
rect(100, 100, 100, 100);
translate(0, 0, -150);
secondframe = false;
}
if (firstframe) {
background(0);
firstframe = false;
secondframe = true;
}
fill(255, 0, 0);
rect(100, 0, 100, height);
}
basically, background is drawn on the first frame. green square is drawn on the next. red stripe is drawn every frame. one would think that drawing the red rect later would draw over the green square, no?
after some digging, i found out a bit about the z-buffer...clearing it fixes this problem. uncomment the first line in draw() to see what i mean.
so, what *exactly* is the z-buffer? is it a processing thing, or a java thing, or a drawing-with-computers thing in general? pleez edumacate me