Akward behaviour of random colours on screen

When i run the following program ,the program doesn’t run as expected it only works fine when i wake my laptop from sleep when the program is still running in the background.
Basically i was trying to make a screen saver that i saw in raspberry pi which randomly generated hues of colour on 9 tiles of the screen .

#include "testApp.h"

float  R,G,B;


//--------------------------------------------------------------
void testApp::draw(){

R = ofRandom(0,255);
G = ofRandom(0,255);
B = ofRandom(0,255);

ofSetColor(R, G, B);
ofFill();
ofRect(0, 0, ofGetWidth()/3, ofGetHeight()/3);

ofSetColor(R,G,B);
ofFill();
ofRect(ofGetWidth()/3 +5, 0, ofGetWidth()/3, ofGetHeight()/3);

ofSetColor(R, G, B);
ofFill();
ofRect(2*ofGetWidth()/3 +10, 0, ofGetWidth()/3, ofGetHeight()/3);

ofSetColor(R, G, B);
ofFill();
ofRect(ofGetWidth()/3 + 5, ofGetHeight()/3 +5, ofGetWidth()/3, ofGetHeight()/3);

ofSetColor(R, G, B);
ofFill();
ofRect(0, ofGetHeight()/3 +5, ofGetWidth()/3, ofGetHeight()/3);

ofSetColor(R, G, B);
ofFill();
ofRect(0, 2*ofGetHeight()/3 +10, ofGetWidth()/3, ofGetHeight()/3);

ofSetColor(R, G, B);
ofFill();
ofRect(2*ofGetWidth()/3 + 10, ofGetHeight()/3 +5, ofGetWidth()/3, ofGetHeight()/3);

ofSetColor(R, G, B);
ofFill();
ofRect(ofGetWidth()/3 + 5, 2*ofGetHeight()/3 +10, ofGetWidth()/3, ofGetHeight()/3);

ofSetColor(R, G, B);
ofFill();
ofRect(2*ofGetWidth()/3 + 10, 2*ofGetHeight()/3 +10, ofGetWidth()/3, ofGetHeight()/3);


}

I think you need to choose new random values between every rectangle you draw. ie:

R = ofRandom(0,255);
G = ofRandom(0,255);
B = ofRandom(0,255);

ofSetColor(R, G, B);
ofFill();
ofRect(0, 0, ofGetWidth()/3, ofGetHeight()/3);

R = ofRandom(0,255);
G = ofRandom(0,255);
B = ofRandom(0,255);

ofSetColor(R,G,B);
ofFill();
ofRect(ofGetWidth()/3 +5, 0, ofGetWidth()/3, ofGetHeight()/3);

otherwise, they will all have the same color value.

the results are coming fine on windows now , i dont know how …but on mac they are not
here are the screen shots

I get uniform color changes on windows but on mac this happens:

of_vid.zip (1.6 MB)

the former result is what i wanted on mac , is it a bug or what ?

please tell me if you want the video of windows too
thanks !

ah can you set vertical sync to be true – in setup add: ofSetVerticalSync(true)

the problem appears to be related to vertical sync / frame ripping:

Thanks ! :smiley: