hey there,
some days ago i started a project using processing. in fact, it’s a simple stuff: it would allow me to compose a certain image using others as “pixels”. this image explains a little bit more what i mean:
http://twitpic.com/oat56
although the simple “animations” i’ve made (translating z-axis), the whole stuff worked fine, with a good framerate.
now i’m trying to do tha same thing with OF. first i loaded all the images as ofImages (about 72 images) and drawing them after that (there are something arround “10000 pixels”. each one is represented by one that 72 ofImages). everything was going fine when i noticed that i couldn’t get more than 7 FPS. here’s what i am doing:
void draw(){
glEnable(GL_DEPTH_TEST);
ofBackground(0, 0, 0);
int index = 0;
int cellsize = 15;
int columns = img.width / cellsize; // Calculate # of columns
int rows = img.height / cellsize; // Calculate # of rows
unsigned char* pixels = img.getPixels();
ofFill();
// Begin loop for columns
for ( int i = 0; i < columns; i++) {
// Begin loop for rows
for ( int j = 0; j < rows; j++) {
int x = i*cellsize; // x position
int y = j*cellsize; // y position
int loc = (x + y*img.width)*3; // Pixel array location
int r = pixels[loc]; // Grab the color
int g = pixels[loc+1];
int b = pixels[loc+2];
float brightness = (0.2126*r) + (0.7152*g) + (0.0722*b);
float factor = timer;
int z = (factor) * (brightness)-10;
ofPushMatrix();
ofTranslate(x, y, (z*30));
//ofSetColor(255, 255, 255);
ofSetColor(r, g, b, 255);
index = ((index+1)%nImages);
img_pixels[index].draw(0, 0, cellsize, cellsize);
ofPopMatrix();
}
}
glDisable(GL_DEPTH_TEST);
}
the problem is in line
img_pixels[index].draw(0, 0, cellsize, cellsize);
removing it gives me high fps again, but not what i want… how could i do the same thing, but with a greater framerate?
ps: how could this be slower than a processing sketch? ideas of why?
btw, i’m a big fan of oF: what a awesome project!
thanks to everybody involved on this (and for that that eventually could help me)!