Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

P2D and set() behave strange

$
0
0
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)

  1. final int sz = 512;
  2. final int sz2 = sz*sz;
  3. final int n = 1000;

  4. int npoints;
  5. color c;

  6. void setup(){
  7.   //size(sz,sz    );   // this works OK
  8.   size(sz,sz,P2D);   // this behave strange
  9.   background(255);
  10.   color c = color(random(255), random(255), random(255));
  11. }

  12. void draw(){
  13.   for (int i=0;i<n; i++){    // loop over some chunk of workitems
  14.     int id=npoints%sz2;    // workitem id
  15.     if (id==0){ c=color(random(255), random(255), random(255));  }  // new screen start here
  16.     int ix=id%sz; int iy=id/sz;    // indexes of pixel
  17.     set( ix,iy, c  );
  18.     npoints++;
  19.   } 
  20. }
  21.  
NOTE - if you ask why the hell I tried such silly way of rastering over the whole screen, it is because I use processing to debug Kernels for OpenCL, and there varibale "id" is index of workitem 



Viewing all articles
Browse latest Browse all 1768

Trending Articles