Bug 1521 : pixelShift in OpenGl crash
Last modified: 2010-03-22 15:01




Status:
RESOLVED
Resolution:
INVALID -
Priority:
P2
Severity:
normal

 

Reporter:
janebeta7
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2010-03-20 10:30
I have this code, with OPENGL doesn't work, I know that there is a bug with
updatePixels and Opengl, but How can i solve?

import processing.opengl.*;
void setup(){
size(1024,768,OPENGL);
smooth();
background(0);
noCursor();

}
void draw(){
fill(255);
ellipse(mouseX,mouseY,100,100);
pixelShift(1,0);
}


void pixelShift(int xshift, int yshift) {
loadPixels();
for (int y=1; y < height; y++) {
for (int x=1; x < width; x++){
if ((x+xshift < width) && (x+xshift > 0)) {
if ((y+yshift < height) && (y+yshift > 0)) {
pixels[x + (y*width)] = pixels[(x+xshift)+ ((y+yshift)*width)];
}
}

}
}
updatePixels();
}


version, 1.1
Operating System: windows x
Additional Comment #1 From fry 2010-03-22 15:01
that's not a processing bug, that code extends out of the pixels[] array so
you'll get an ArrayIndexOutOfBoundsException.

also, if you're doing load/updatePixels on every frame, P3D will probably
be faster anyway.