Hello.
The following code acts a bit odd. It seems as though the depth/zbuffer is empty when using a P3D offscreen context with PGraphics:
Note the fill colors do not work, and when moving the mouse the offscreen context(s) inherit the background color as a fill color when drawn.
I am assuming I am doing something wrong. Id love to know what.
Processing 123/OS X 10.4.8 latest drivers, Macbook Pro.
Code:
//create offscreen graphics buffers
PGraphics context1;
PGraphics context2;
void setup()
{
size(300,300,P3D);
//initialize our offscreen graphics buffers
context1 = createGraphics(width-20,height-20, P3D);
context2 = createGraphics(width-20,height-20, P3D);
}
void draw()
{
background(mouseY,0,0);
lights();
pushMatrix();
translate(58, 48, 20);
rotateY(0.5);
fill(200,0,200);
stroke(200,0,200);
box(40);
popMatrix();
if(mousePressed)
{
//only draw our contexts if we need them..
context1Draw();
context2Draw();
noTint();
image(context1,10,10);
tint(0,0,0,mouseX);
image(context2,10,10);
}
}
void context1Draw()
{
context1.beginDraw();
context1.background(200);
context1.lights();
context1.fill(200,200,0);
context1.stroke(200,200,0);
context1.translate(58, 48, 0);
context1.rotateY(0.5);
context1.box(40);
context1.endDraw();
}
void context2Draw()
{
context2.beginDraw();
context2.background(100);
context2.lights();
context2.fill(0,0,200);
context2.stroke(0,0,200);
context2.translate(58, 48, 0);
context2.rotateY(-0.5);
context2.sphere(40);
context2.endDraw();
}