autoclear problem 0.6 windows

hi,

in my app I don’t want to have autoclear of background.

in ofAppGlutWindow I found the following which can’t be meant working like that I guess…

if ((bClearAuto == true || windowMode == OF_WINDOW) || nFrameCount < 3){
glClearColor(bgPtr[0],bgPtr[1],bgPtr[2], bgPtr[3]);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

means in Window Mode it doesn’t matter if bClearAuto is true or false …

anyway I started with OF finally and clean up my old thrashy vj engine and try to build it on top of OF.
thx for the good works,

Robert

www.1n0ut.com

Do you mean like this http://www.openframeworks.cc/documentat-…-groundAuto ?

if so, just call ofSetBackgroundAuto(false) in your testApp::setup()

P.S. That documentation is quite old, but most of it is still relevant.

This is actually a really weird bug I’ve been dealing with too. Consider the following code:

  
  
class testApp : public ofBaseApp {  
public:  
	int frameCount;  
  
	testApp() {  
		frameCount = 0;  
	}  
  
	void setup() {  
		ofSetBackgroundAuto(false);  
		ofSetFrameRate(3);  
	}  
  
	void update() {  
	}  
  
	void draw() {  
		if(frameCount % 3 == 0) {  
			ofBackground(255, 255, 255);  
			ofSetColor(0);  
			ofRect(ofRandom(0, ofGetWidth()), ofRandom(0, ofGetHeight()), 100, 100);  
		}  
		frameCount++;  
	}  
};  
  

You would expect it to draw a new rectangle to the screen every second, replacing the old one.

Instead, what happens varies with whether you are fullscreen or not, and (on my video card) the antialiasing settings.

Fullscreen + antialiasing is overridden to 2x or greater: works correctly.

Windowed + antialiasing is overridden to 2x or greater: draws the rectangle, then two frames of white background, then new rectangle, etc.

Windowed + antialiasing is controlled by app: same as above.

Fullscreen + antialiasing is controlled by app: draws rect1, then white frame, then rect1, then new rect2, then white, then rect2, then rect3… like there are two buffers. I’m guessing this is what the ofAppGlutWindow.cpp is referring to when it says:

  
  
// I don't know why, I need more than one frame at the start in fullscreen mode  
// also, in non-fullscreen mode, windows/intel graphics, this bClearAuto just fails.  
// I seem to have 2 buffers, alot of flickering  
// and don't accumulate the way I expect.  
// with this line:   if ((bClearAuto == true) || nFrameCount < 3){  
// we do nFrameCount < 3, so that the buffers are cleared at the start of the app  
// or else we have video memory garbage to draw on to...  
  

again the problem is the ‘if’ command according to boolean logic it means when we are in windowed mode always enter the code part below, so ofSetBackgroundAuto(false); has no effect in windowed mode in Fullscreen it is working of course after the nFrameCount >=3 …

if ((bClearAuto == true || windowMode == OF_WINDOW) || nFrameCount < 3){
glClearColor(bgPtr[0],bgPtr[1],bgPtr[2], bgPtr[3]);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

}

I was trying this out on a windows machine, just to mention used OS

Wow, somehow I completely missed this.

So yeah, that explains two of the cases I was describing.