We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexSuggestions & BugsSoftware Bugs › OPENGL PImage/PGraphics pointer bug
Page Index Toggle Pages: 1
OPENGL PImage/PGraphics pointer bug? (Read 1689 times)
OPENGL PImage/PGraphics pointer bug?
May 8th, 2005, 3:13pm
 
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...
Re: OPENGL PImage/PGraphics pointer bug?
Reply #1 - Jul 28th, 2005, 5:14am
 
verified as a general opengl pixels problem:
http://dev.processing.org/bugs/show_bug.cgi?id=91
Page Index Toggle Pages: 1