Skip to main content
gamedev.net
🔒 Locked

Timing

Started by patroclus 7 replies 2k views
Original Post
patroclus
patroclus
I know now why I could not make my game run at a certain framerate. The API GetPerformanceCOunter does not work fine. In windows 98SE my game runs perfectly, and so does this API, but not in windows XP (maybe beacuse it''s an NT) Any help??? How can I solve this?? Thanks!!
patroclus
patroclus
None of you ever used QueryPerformanceCounter??

I don''t know what to do..
IndirectX
IndirectX
What are you trying to do and what exactly isn''t working?
---visit #directxdev on afternet <- not just for directx, despite the name
Sly
Sly
As mentioned in the DelphiGames mailing list, QueryPerformanceCounter has issues with certain types of hardware where the value returned is not accurate. In my case, it jumped every five seconds or so, causing time-dependent animation to stutter.

GetTickCount has remarkably low resolution (55ms on Windows 95), so it cannot be used to get accurate framerates, but it does work reliably.

Another option is timeGetTime in the multimedia libraries. I have not tried this one myself, but MSDN states that it has 1ms resolution on Windows 95 and ~5ms on Windows NT, depending on hardware.
patroclus
patroclus
InDirectX, my problem is that I use QueryPerformanceCounter in order to get a fixed framerate in a game, but the timing is no 100% accurate and FPS drops and raises slightly.

Sly, then, what do you suggest to use?? What do you use for timing??

In windows XP, TimeGettime offers a poor resolution (more or less like GettickCount).

Thank you
IndirectX
IndirectX
quote:
Original post by patroclus
InDirectX, my problem is that I use QueryPerformanceCounter in order to get a fixed framerate in a game, but the timing is no 100% accurate and FPS drops and raises slightly.


That's a feature.
quote:

Sly, then, what do you suggest to use??


You can either fix the feature or use timeGetTime.
quote:

What do you use for timing??


I fix the feature.
quote:

In windows XP, TimeGettime offers a poor resolution (more or less like GettickCount).


Use timeBeginPeriod and timeEndPeriod as described in the docs for timeGetTime to get 1 ms resolution from it [timeGetTime].

[edited by - IndirectX on June 19, 2002 6:36:47 PM]
---visit #directxdev on afternet <- not just for directx, despite the name
Sly
Sly
InDirectX, that is a very educational article you have there. It is a lot clearer now.
patroclus
patroclus
Yes, TimeGetTime works reliably using TimeBeginPeriod and setting it to 1ms resolution.

Up to date, it''s the best solution I''ve ever tried to time low FPS such as 50 or 60 FPS.
In my game, the FPS raises and drops slightly using timeGetTime, but makes no problem.

IndirectX, do you think I should try to fix QueryPerformanceCounter instead of using this?? Once I fix it, will the FPS still raise and drop slightly??

the problem with this solution, is that I don''t understand very well how it works after reading the articles. Maybe you could help me a bit.. I''ll apreciate it.

Thank you very much for your help.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.