Playing around with visual feedback I encountered this oddity:
Take the sketch below and copy in a 00.jpg of any size smaller than 600,600 in the DATA folder.
In P3D mode it works like supposed to where it:
1. Makes a copy of the current pixel array to buffer.
2. Displays the buffer slightly misaligned behind whatever is going to be in front.
3. Quite often displays an image at a random position on screen.
Code:
import processing.opengl.*;
PImage buffer;
PImage img = new PImage();
void setup(){
size(600,600,P3D);
buffer = new PImage(width,height);
img = loadImage("00.jpg");
background(255);
Arrays.fill(buffer.pixels,0xFF0000);
}
void draw(){
loadPixels();
System.arraycopy(pixels,0,buffer.pixels,0,pixels.length);
buffer.updatePixels();
background(255);
tint(255,255);
pushMatrix();
translate(random(-1,1),random(-1,1),-1);
image(buffer,0,0);
popMatrix();
if(random(10)<1){
tint(255,200);
image(img,random(width-img.width),random(height-img.height));
//stroke(0);
//noFill();
//rect(random(width/2),random(height/2),random(width/2),random(height/2));
}
}
When in P3D mode, buffer.updatePixels(); seems to be redundant.
When in OPENGL mode:
If buffer.updatePixels(); is missing the images don't stick to the buffer, and the buffer doens't seem to get updated.
If buffer.updatePixels(); is present, the previous screen is displayed scaled down in the randomly placed img instead of where buff is.
If the commenting in the last if(random... is reversed, so that only rects are drawn, it works like expected in both P3D and OPENGL. And, if entire if(random... section is moved to between background and tint, the previous screen is drawn _both_ in img and buffer when in OPENGL. And this is why my guess is that there is a error in the PImage/PGraphics in OPENGL.
Though, confusingly enough, this rocade also causes that if going back to P3D, images are not drawn anymore...