Flickering With Glut

I am pretty new to OpenGl, so I am using glut, but with user input the problem is that the image begins to flicker, I think it is because of glutPostRedisplay(); in my glutKeyboardFunc but I’m not sure, is there any way to prevent this?

You can try enabling vsync in your graphics card control center.

N.

You really put glutPostRedisplay() in the glutKeyboardFunc ?
What OS are you working on?

Windows. Should that really make a difference? And should glutPostRedisplay not be in the KeyboardFunc? The problem is that if I remove it, it doesn’t show the changes that need to be made.

In the usual case you put glutPostRedisplay() at the end of the function you pass to glutDisplayFunc().

N.

Well, I just tried that, and it constantly flickers, I’m still not sure why. Sorry.

I found out a simple fix for my problem, all I had to do was add GLUT_DOUBLE to the display mode. Thanks all. :smiley:

Haha, nice spot, I forgot about this.
Yes front buffer rendering brings the grand mother of all tearing :smiley:

I know it’s an old post, so sorry for bringing it up again, but I am having the same problem when porting my GLUT application from Mac to Windows.

As I had earlier passed GLUT_SINGLE to glutInitDisplayMode (I am not sure what it did or why I had it there) I replaced this parameter with GLUT_DOUBLE. But instead of a flickering window I now get an empty window :frowning: In fact, I can see right through the window, so it’s not just empty, its hollow… Any ideas on what to look for in the code to make this work?

If it matters, note that I am passing the following function to glutTimerFunc in order to be able to control the frame-rate:


void TimerFunc(int extra)
{
    glutPostRedisplay();
    glutTimerFunc(1000 / fps, TimerFunc, 0);
}

Probably just missing a glutSwapBuffers(); call right at the end of your display function.

Yes, I was missing that… thanks!