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.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › Points in P3D vs. OPENGL
Page Index Toggle Pages: 1
Points in P3D vs. OPENGL? (Read 1784 times)
Points in P3D vs. OPENGL?
May 9th, 2005, 5:10am
 
Hello All,

I'm doing a quick Histogram of a webcam feed.  The brightness of the pixels translates into the length of a line in the z direction.  The following code runs OK in P3D:

********
import processing.video.*;

Capture webCam;

int vidW = 320;
int vidH = 240;
int winX = vidW*2;
int winY = vidH*2;
int DIAMETER=2;
int W=width/2;
int H=height/2;
String render;

void setup() {
 size(winX, winY, P3D);
 println(Capture.list());
 String captureDevice = "IIDC FireWire Video";
 webCam = new Capture(this, captureDevice, vidW, vidH, 30);
}


void captureEvent(Capture webCam) {
 webCam.read();
}

void draw() {

 int row;
 int pix[] = webCam.pixels;
 color c;
 int r,g,b;
 float bri;  

 background(0);
 translate(vidW/2, vidH/2);

 for(int y=0; y<vidH; y+=2) {
   row = y*vidW;
   for(int x=0; x<vidW; x+=2) {  
     c = pix[row + x];
     b = (c & 0x000000FF)    ;
     g = (c & 0x0000FF00)>>8 ;
     r = (c & 0x00FF0000)>>16;
     bri = (r+g+b)/3.0;
     stroke(bri, bri, bri, 20);
     line (x, y, 0, x, y, bri-5);
     stroke(255,0,0, bri);
     point(x, y, bri);
   }
 }
}
********

If I import the OPENGL library and run the code, it runs smoother, but the points are behave erratically.  Only a few points appear and seemingly in random places.

Any ideas why the points don't render correctly in OPENGL?  What mistake am I doing?
Page Index Toggle Pages: 1