Screen Pixels Manipulations

I’m coding an app that creates fractals, and I need to calculate nearly 100000 points per draw loop, so I need to be as efficient as possible.

Currently I’m drawing 1x1 rectangles, and I’m sure that this isn’t the best way to do it. Processing has a pixels array that change the screen pixels, and it is WAY faster than drawing pixel-sized squares into the canvas. I was wondering if OF has a similar command.

I read this and Arturo was talking about PBO (Pixel Buffer Object) and I would really appreciate if someone explains or link me a website/video about this, beacause I need to know how to fast manipulate screen pixels in OF.


1 Like

You can create an ofImage, set this image pixels, and display it. This is the solution in the thread you linked to.
Does it suits your case ?

in ofApp.h

ofImage img ;

in ofApp.cpp

void ofApp::setup(){
    // Initialize the image size to be the same than the window size
    img.allocate( ofGetWidth(), ofGetHeight(), OF_IMAGE_COLOR );

void ofApp::update(){
    ofPixels& pixels = img.getPixels();
    int y = 0;
    for(auto line: pixels.getLines()){
        int x = 0;
        for(auto pixel: line.getPixels()){
            pixel[0] =  // some value
            pixel[1] =  // some value
            pixel[2] =  // some value
void ofApp::draw(){
1 Like