I thought I had completed my first project successfully, but have run into an issue in testing. I have several layers of images with blending modes and transparency that fade in and out over long periods of time (hours). If I run the program long enough the images turn solid white. Is this a memory issue? I intend to let it run for weeks or months. I have 16 images layered—I’m only posting a segment of the code as an example.
I’m on a Mac running OS 10.8.5 with a NVIDIA GeForce 9400M 256 MB graphics card.
Here’s the class where I change images over time:
//--------------------------------------------------------------
void opaCont::setup(){
count3 = 255;
a = true;// start the stopwatch
//Establish time delay range------------------------------------
rand1 = ofRandom(.1, .01);
rand2 = ofRandom(1, .01);
rand3 = ofRandom(.1, .01);
rand4 = ofRandom(1, .01);
}
//--------------------------------------------------------------
void opaCont::update(){
//Opacity Up----------------------------------------------------
if (a){
count4 = 0;
opacity = count;
stopwatch.start();
count = stopwatch.elapsedSeconds() * rand1;
}
if (count >= 255){
a = false;
b = true;
stopwatch.reset();
}
//Opacity Hold--------------------------------------------------
if (b){
count = 0;
opacity = 255;
stopwatch2.start();
count2 = stopwatch2.elapsedSeconds() * rand2;
}
if (count2 >= 255){
b = false;
c = true;
stopwatch2.reset();
}
//Opacity Down--------------------------------------------------
if (c){
count2 = 0;
opacity = count3;
stopwatch3.start();
count3 = 255 - stopwatch3.elapsedSeconds() * rand3;
}
if (count3 == 0){
c = false;
d = true;
stopwatch3.reset();
}
//Transparancy Hold---------------------------------------------
if (d){
count3 = 255;
opacity = 0;
stopwatch4.start();
count4 = stopwatch4.elapsedSeconds() * rand4;
}
if (count4 >= 255){
a = true;
d = false;
stopwatch4.reset();
}
}
And here's where I draw the images:
void testApp::draw(){
ofSetColor(255);
img1.setAnchorPercent(0, 0);
img1.draw(450, 20);
ofSetColor(opaCont1.opacity, opaCont1.opacity);
ofEnableBlendMode(OF_BLENDMODE_MULTIPLY);
img2.setAnchorPercent(0, 0);
img2.draw(450, 20);
ofDisableBlendMode();
ofSetColor(opaCont2.opacity, opaCont2.opacity);
ofEnableAlphaBlending();
img3.setAnchorPercent(0, 0);
img3.draw(450, 20);
ofDisableAlphaBlending();
ofSetColor(opaCont3.opacity, opaCont3.opacity);
ofEnableAlphaBlending();
img4.setAnchorPercent(0, 0);
img4.draw(450, 20);
ofDisableAlphaBlending();