Hi,
this code works OK with default render ( fills up the screen from top to down ), however with P2D it makes strange things (makes some strips like a comb). I think it is because of some incompactibility of set() function with P2D render (I guess something like bad synchronization of framebuffer operations...).
I use processing 2.0b6 (maybe in 2.0b7 it is already repaired, I don't know)
- final int sz = 512;
- final int sz2 = sz*sz;
- final int n = 1000;
- int npoints;
- color c;
- void setup(){
- //size(sz,sz ); // this works OK
- size(sz,sz,P2D); // this behave strange
- background(255);
- color c = color(random(255), random(255), random(255));
- }
- void draw(){
- for (int i=0;i<n; i++){ // loop over some chunk of workitems
- int id=npoints%sz2; // workitem id
- if (id==0){ c=color(random(255), random(255), random(255)); } // new screen start here
- int ix=id%sz; int iy=id/sz; // indexes of pixel
- set( ix,iy, c );
- npoints++;
- }
- }