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 › get (pixels) problems in openGL
Page Index Toggle Pages: 1
get (pixels) problems in openGL (Read 1954 times)
get (pixels) problems in openGL
May 22nd, 2005, 7:29pm
 
(sorry about all this bug reporting, I hope I am not reporting something that has already been talked about... I could not find it)

The following code works in P3D renderer and the default, but not with OpenGL.

(the little box on top-left of the cursor detects the color underneath and colors the big box at the bottom)

import processing.opengl.*;

Form aform;
color pixCol;

void setup() {
 size(400,400, OPENGL);  // TRY P3D or default and it works fine !!!
 aform = new Form(20, 200);
}

void draw() {
 background(122);  
 fill(204, 102, 0);
 rect(10, 50, 40, 100);
 fill(204, 2, 130);
 rect(210, 200, 40, 120);
 fill(4, 202, 220);
 rect(150, 100, 120, 40);  
 fill(44, 202, 220);
 rect(290, 5, 80, 120);
 fill(24, 2, 120);
 rect(350, 100, 450, 140);  
 aform.update();
}

class Form {
 int x;
 int y;

 Form(int _x, int _y) {
   x = _x;
   y = _y;
 }

 void update(){
   x = mouseX - 4;
   y = mouseY - 4;
   pixCol = get(x, y);
   noFill();
   rect(x-3, y-3, 6, 6);
   fill(pixCol);
   rect(0, 300, 400, 100);
 }
}
Re: get (pixels) problems in openGL
Reply #1 - May 23rd, 2005, 1:38pm
 
It gets worse when you use pixels[]
Code:

//import processing.opengl.*;
Form aform;
color pixCol;
void setup() {
size(400,400);//, P3D);//OPENGL); // TRY P3D or OPENGL !!!
aform = new Form(20, 200);
}
void draw() {
background(122);
fill(204, 102, 0);
rect(10, 50, 40, 100);
fill(204, 2, 130);
rect(210, 200, 40, 120);
fill(4, 202, 220);
rect(150, 100, 120, 40);
fill(44, 202, 220);
rect(290, 5, 80, 120);
fill(24, 2, 120);
rect(350, 100, 450, 140);
aform.update();
}
class Form {
int x;
int y;
Form(int _x, int _y) {
x = _x;
y = _y;
}
void update(){
x = mouseX;
y = mouseY;
//pixCol = get(x, y);
loadPixels();
pixCol = pixels[x + y * width];
noFill();
//rect(x-3, y-3, 6, 6);
fill(pixCol);
rect(0, 300, 400, 100);
}
}

What the hell is going on?
Re: get (pixels) problems in openGL
Reply #2 - May 23rd, 2005, 11:32pm
 
get/set are fairly broken in opengl and i'll try to fix it soon.

but the java2d renderer and P3D work fine for me with this example. perhaps you could describe the problem?
Re: get (pixels) problems in openGL
Reply #3 - Jul 28th, 2005, 4:37am
 
filed in the bugs db:
http://dev.processing.org/bugs/show_bug.cgi?id=91
closing thread.
Page Index Toggle Pages: 1