• Advertisement
Sign in to follow this  

Game Jerky with Vsync Off

This topic is 1892 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys,

I just noticed that my game is jerky when Vsync is off. Everything is silky smooth when it's on. I really don't know where to start.

Here is my loop:

while(msg.message != WM_QUIT){
if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else{
QueryPerformanceCounter((LARGE_INTEGER*)&cur_time);
time_span=(cur_time-last_time)*time_factor;
last_time=cur_time;
game->heartbeat(timespan);
}

My objects are timespan based like so:

position.x+=velocity.x*timespan;
position.y+=velocity.y*timespan;

What do you think it could be ?

I'm using Win 8 Pro if that matters.

Please help, thanks.

Share this post


Link to post
Share on other sites
Advertisement
Vsync has probably capped you to ~60 frames per second, turning it off who knows but its no longer as consistant.
I would probably change my object's so they move independantly of the time between frames.

edit: After reading Erik's reply, could you describe the jerkiness more? Edited by yewbie

Share this post


Link to post
Share on other sites
You can't get perfect smoothness without vsync, that's what it's for. Your screen only updates at a certain rate (usually 60 Hz), so if your game updates at 120 FPS, you will actually have updated 2 frames between each frame you see on screen.
This is further complicated by the fact that the screen doesn't update instantaneously, so if you update too fast then the top half of the screen might display the image from one frame, while the bottom half of the screen displays the image from the next frame, which leads to tearing (you see a horizontal line where your image is offset).
In addition to that, and what probably makes your game feel jerky, is that you will rarely update at an exact multiple of the screen refresh rate, so if you update 2.5 times faster than your monitor, then between the frames you actually see you will sometimes have moved 2 frames and sometimes 3 frames.

Share this post


Link to post
Share on other sites
The jerkiness is probably a combination of factors, including screen tearing (where half the screen is showing the previous frame), as mentioned by Erik Rufelt.

Another often overlooked situation is that each frame doesn't take exactly the same amount of time to render. Depending on what's on screen, what the user is doing and what game logic is going on behind the scene, the time in milliseconds to render a given frame can vary quite a lot. The human brain is good at perceiving subtle differences in the timing of periodic events, which is what you're seeing as jerkiness.

If you turn on VSync, you're forcing each frame to take the same amount of time, so animation is perceived to be considerably smoother.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement