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 › Accessing pixels[] with noLoop()
Page Index Toggle Pages: 1
Accessing pixels[] with noLoop() (Read 733 times)
Accessing pixels[] with noLoop()
Oct 8th, 2007, 8:22am
 
I am not sure if this is intentional or a bug, but using the following code with the OpenGL renderer, loadPixels() and the pixels[] array returns 0. If you comment out the noLoop line then it works fine. Any ideas?

Also, is it not possible to use background() with the OpenGL renderer?

Thanks!

Quote:


import processing.opengl.*;

PImage bg;

void setup(){
 size(200, 200, OPENGL);
 bg = createImage(200, 200, RGB);
 for(int i=0; i < bg.pixels.length; i++) {
   bg.pixels[i] = color(0, 150, i % bg.width * 2);
 }
 noLoop();
}

void draw(){
 //background(bg);
 image(bg, 0, 0);
}

void mousePressed(){
 loadPixels();
 // Print out the BLUE value of the PIXEL
 int b = pixels[mouseY*width+mouseX] & 0xFF;
 println(b);
 redraw();
}


Re: Accessing pixels[] with noLoop()
Reply #1 - Oct 10th, 2007, 5:34am
 
Well it looks like this comes under the all encompassing:

Bug 91 : blend(), get(), set(), copy(), loadPixels, updatePixels() are broken when used with OPENGL
http://dev.processing.org/bugs/show_bug.cgi?id=91
Re: Accessing pixels[] with noLoop()
Reply #2 - Oct 10th, 2007, 1:25pm
 
yes, that's correct. background() uses set(). need to get those straightened out.
Re: Accessing pixels[] with noLoop()
Reply #3 - Oct 10th, 2007, 2:25pm
 
good news, just fixed bug 91 for the next release (which should be coming along in the next few days).
Re: Accessing pixels[] with noLoop()
Reply #4 - Oct 10th, 2007, 2:33pm
 
Thanks and Cool!
Looking forward to it.
Keep up the good work Smiley
Page Index Toggle Pages: 1