The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Windows and Linux timing differences
Justin Agrell
Guest

Source can be found:
https://github.com/quadcricket/legend-of-pandora/blob/master/source/common/source/main.c

I've been trying to wrap up my old open source game to move on to my
SDL2 project. I just got it working on Windows 7 and I've noticed the
timing is noticeably off. Characters animate incorrectly, or move too
slowly on Windows.

I thought I implemented time-based movement correctly but it's likely
I'm missing something simple.

I use SDL_GetTicks() to record the length of each run cycle and then
moving characters so many pixels (or changing key-frames) whenever so
many milliseconds pass.

Is there an adjustment I need to make to SDL? Do I just need to adjust
my definitions for Windows? Is my code just wrong?

Any help would be appreciated.

-Justin
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Windows and Linux timing differences
Ryan C. Gordon
Guest

Quote:
I've been trying to wrap up my old open source game to move on to my
SDL2 project. I just got it working on Windows 7 and I've noticed the
timing is noticeably off. Characters animate incorrectly, or move too
slowly on Windows.

I thought I implemented time-based movement correctly but it's likely
I'm missing something simple.

If you're on SDL 2.0.3, there's a bug we fixed since:

https://hg.libsdl.org/SDL/rev/7454bfce9202

Basically, we usually didn't use the high-resolution timer on Windows by
accident, so simple timing scenarios where you should have had a 1ms
resolution were out of whack by an order of magnitude.

--ryan.


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Windows and Linux timing differences
Sik


Joined: 26 Nov 2011
Posts: 905
The amusing thing:

2015-12-01 2:44 GMT-03:00, Ryan C. Gordon:
Quote:
https://hg.libsdl.org/SDL/rev/7454bfce9202

"An existing hint lets apps that don't need the timer resolution changed avoid
this, to save battery, etc, but this fixes several problems in timing, audio
callbacks not firing fast enough, etc."

With games (the most common use for SDL, I believe?) the battery
saving issue is the exact opposite because the high resolution timer
allows them to enter a sleep loop without risking a framerate drop
(otherwise they have to resort to busy loops or the like which pushes
their CPU usage to 100%).
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org