Skip to main content
gamedev.net
🔒 Locked

Fullscreen Flicker Problem

Started by 11235813 4 replies 800+ views
Original Post
11235813
11235813
Hello! 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; } Any suggestions? I'm really stuck!!
Deception666
Deception666
I think we need some more information.

Is the application single or double buffered?
11235813
11235813
I guess it is "double" b/c:

In the GLUT version, I am calling the following:

glutInit(&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
glutCreateWindow("test");
glutFullScreen();
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glClearColor (1.0, 1.0, 1.0, 1.0);
glShadeModel (GL_FLAT);
glutDisplayFunc(display);
glutReshapeFunc(reshape);

then:

void reshape(int w, int h)
{
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-512.0, 512.0, -384.0, 384.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

void display(void)
{
if(once == 1) {
glClear(GL_COLOR_BUFFER_BIT);
once = 0;
}
// DRAW STUFF HERE
glutSwapBuffers();
glutPostRedisplay();
}

The non-GLUT version is similar, based off of NEHE examples (
http://nehe.gamedev.net/lesson.asp?index=01), set to be ORTHO2D and with the same display code.


Yonibear
Yonibear
I guess the problem is the following:
If you use Doublebuffering, you have 2 buffers which are alternately shown on the screen.
Since you are only clearing one of the buffers, the other one still contains the old content, i.e. the desktop.

You should take a look at "Accumulation Buffers". They exist just for this purpose. Additionally, they deal with Color Scaling and often have pixel formats with a wider range to avoid saturation.
Eitsch
Eitsch
Yonibear: sounds good. accum buffer isnt hardware accelerated on most hardware. try to clear several first frames . not only the first.
Yonibear
Yonibear
Ok, but clearing the buffer several times at the start won't solve the problem. On each buffer the frames drawn to the other buffer will be missing.
Additionally, the color buffer amy always be corrupted, for example when the OpenGL window is overlapped by another window.

The right way would be to implement some sort of manual double buffering by rendering to a Framebuffer Object. FBOs are always single-buffered, so you can accumulate the scene on them. After that, you should render the texture attached to the FBO with a fullscreen quad to copy it to the back buffer.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.