| Summary: | Timer is too inaccurate | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Sik <sik.the.hedgehog> |
| Component: | timer | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | HG 2.0 | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Attachments: | Source code for a small test program showing the issue. Put in the public domain. | ||
Ugh, forget that, was an error on my side after all. That still doesn't explain why configure doesn't notice the presence of clock_gettime, which I think is important to fix since it's definitely much more accurate than gettimeofday (especially if the current date changes for some reason). While testing I noticed that using -std=c99 makes time.h not provide clock_gettime nor anything related, is that relevant? Pass the flag --enable-clock_gettime to configure to have it check if clock_gettime is available (off by default). |
Created attachment 814 [details] Source code for a small test program showing the issue. Put in the public domain. I'm trying to implement a framerate system in my game using SDL timers (both SDL_GetTicks and the performance counter), but I get at most 30 FPS for some reason. I even stripped down the program to the most minimum instance (so only that was running) and still ended up with 30 FPS (with frameskip). I checked what value SDL_GetPerformanceFrequency returned and it was 1000000, meaning it was using gettimeofday. Had to hack SDL_config.h to make it use clock_gettime instead, which for some reason wasn't detected. It still was stuck at 30 FPS. (On that note, I'd get a linker error if I tried to use the resulting library, I'd need to pass -lrt to GCC when building my program to get it to work. May want to check that too, also may be why configure didn't detect clock_gettime) Using Ubuntu 11.04 x86-64 with the February 3 snapshot of the SDL 2.0 Mercurial (the latest one as I write this). Any ideas? PS: attaching the source code of a minimal program showing the issue. Waits for 5 seconds, then shows how many times it called the framerate control function (when working fine it should show around 300). Just build everything together :P Put in the public domain.