I’m working with a very simple 2D/ortho application where I want to clear the background just once at the beginning (so that all shapes leave a trail.) I’m programming in C++ on Windows. It works 100% fine when windowed, but as soon as I run it fullscreen, there is a terrible flicker (and you can see the computer’s desktop behind my app.) I’ve tried with and w/o glut.
In other words, the app starts up with “once = true” then:
if(once) {
glClear(GL_COLOR_BUFFER_BIT);
once = false;
}
I apologize b/c I am somewhat of a beginner. A few things:
1 – Are you saying I should change the refresh rate to 60HZ or not? I have that code (from the NEHE examples) already in my app, not sure what it does other than say fullscreen not suppored.
2 – The “once” is key to my program since I do not want to clear the color buffer each frame. I have a line that moves around the screen and I need to see its trail.
3 – I believe I am using double-buffering, how do I clear both buffers as opposed to one?
If you use double-buffering, then you swap buffers each frame via glutSwapBuffers. It swaps teh back buffer (one you render to) and the front buffer (one you see). The problem is that the back buffer is usually undefined after swapping, so you most probably get a lot of “waste” in it (like the desktop window).
As to a solution of your problem, I don’t really know, because I never did anything similar. I suggest that you render the trail anew each frame if possible, or use the accumulation buffer.
1)Use EnumeDisplaySettings()to get the current settings( So current refresh rate of monitor ).If the current refresh rate is 60 HZ, EnumeDisplaySettings() sets the refresh rate to 60 HZ. If it’s 85HZ, this function sets the refresh rate to 85HZ.
2) Remove once variable and see the results. Does it solve the flicker problem?If not, don’t remove this variable, since this is part of your program.
3)Does glDrawBuffer( GL_BACK ) solve your problem?
I want to clear the background just once at the beginning (so that all shapes leave a trail.)
Then, as a GL beginner, your best bet is use single buffering (or always draw to GL_FRONT and do not use swapbuffers !).