why this is happening?

Hello

I’m new in OpenGL, but I have written very simple app in window or fullscreen mode, where I’m moving (using glTranslatef) a box (GL_QUADS) on the scene. But it flickers a lot!!!. I have Duble Buffering enabled. I also run another thread - server thread, but when I run it, the animation slows down a lot (like 10fps).
What is the best way to do smooth animation? (fixed framerate) Any examples of code? And what am I doing wrong?

Regards

Do you want to post your code

I’m not able to do it right now.

But anyway, I used NeHe code for setting the OpenGL window, then I use also his code for writing the scene. In WinMain I use the while() loop and call DrawGLScene() function and then swap buffers.
Strange thing is, that when I’m animating only a triangle, it looks smooth, but where it goes to quads, the flickers occurs
It looks like the SwapBuffer() function is swaping to fast?!?
And also, how can I reduce the CPU load, because it’s almost 100% now !.

Regards

It would be good if you could post a screenshot or describe the flickering more in detail. Here are some possible reasons for it:

  • Vertical sync is disabled in your desktop properties which means that Swapbuffers won’t wait for vertical sync. This lead to tearing were you see part of the old frame as the current frame is being rendered. Turn vsync back on to solve this.

  • Z-buffer precision issues. Often looks like horizontal flickering lines on polygons that overlap. To solve this, push your near plane out.

  • You are in fact not double buffering for some reason. Check what kind of pixelformat you get (if running under windows).

Thanx for reply!

Originally posted by harsman:
[b]It would be good if you could post a screenshot or describe the flickering more in detail. Here are some possible reasons for it:

  • Vertical sync is disabled in your desktop properties which means that Swapbuffers won’t wait for vertical sync. This lead to tearing were you see part of the old frame as the current frame is being rendered. Turn vsync back on to solve this.
    [/b]

OK. This looks like the effect you’ve described above - I see part of old frame during new one (I think I see). Maybe this is the problem, but how to solve it from code (to be sure that on other PC this will also work OK).?? How to force the SwapBuffer() to wait for VSYNC?

Can someone also post the code for making the frame rate fixed? Something with multimedia timer, or…?

If you’re running windows you can edit the default Vsync behaviour in your graphics drivers panel in the desktop properties. If you want to change it from within your program, use the WGL_EXT_swap_control extension. There are tutorials on using extensions at this site. For the timing issue I suggest you use google or look at the Nehe tutorials here .