View Full Version : Strange result with vertical retrace

10-27-2003, 02:28 AM
I'm doing a really simple opengl program which draws a single triangle which is then moved over the screen with a gamepad.

The thing is that when vertical retrace is enabled the movement is uneven, and when I turn it off it becomes smooth.

For the distans of movement I have tried using a static value and a value depending on frame rate. It turns out that it doesn't matter which I use, the result is still that non-vertical retrace is smoother.

I have played with wglSwapIntervalEXT, but it doesn't help (unless I turn vert-retrace off...)

Any ideas?

I have GF 5600FX, AMD 1600XP

10-27-2003, 05:38 PM
Your movement should be based on time between frames, not based on the refresh rate. There are many discussions of this on this forum (do a search), but you should mention your operating system as each has a different function to get time and some functions have higher time resolution (milliseconds vs. microseconds).

But, use a timer function, take the difference between the 2 at the beginning of each frame and multiply your speed (distance per second) by that the time to determine the new positions. This should give you smoother animation, though refresh off does usually give the best results.

10-27-2003, 11:07 PM
I am calculating the time between each frame and using this to decide the new position of the triangle.

"This should give you smoother animation, though refresh off does usually give the best results.", so what you are saying is that turning the vertical synch off usually gives a better result? How can this be? Is it because of low resolution of the timer?

I am running the prog under win2k.

10-28-2003, 10:05 AM
It really depends on your frame rate vs your refresh rate as well as the times between drawing frames.

With vsync on, your application will wait at the swap buffer call until the vsync has cleared. If your average frame rate is less than the refresh rate then you may have frame drawn, frame drawn, frame skipped (draw function did not call swap buffer before vsync), frame drawn, frame drawn, frame skipped, etc. The problem occurs that your times are 1 frame behind. So, if the previous frame time were 1/60 but your function does not call swap buffers before vsync then it draws your movement for only 1 frame but it took 2 frames, and then the following frame has a time of 2 frames but draws it in 1 frame and therefore it looks jumpy. It does maintain a consistent speed of objects but doesn't always look good. Also, if you have a lot of calculations between some frames and few between others there could be greater inconsistency.

With vsync off, the problem is less noticeable because there is no wait for vsync resulting in less time between calls to the draw function and the CPU is always working never stopping. There will likely still be skipped frames but the time difference will not be as noticeable. Some of the frames that would have been missed with vsync on will be reclaimed with vsync off.

Sorry it is not the best explanation but I hope it helps.

10-28-2003, 02:18 PM
For those who are intersted... The problem is now solved! At last...

Reading the release note for the newest Nvidia driver I saw that running in clone-mode is having a negative effect on 3D performance... Turning clone-mode off fixed everything!