Lx Episode 1 is finally on download.com, so please do your part ;-)

Started by
27 comments, last by Uhfgood 21 years, 6 months ago
This thread has gone way off topic suddenly, but oh well. Life goes on.
quote:Original post by Origin Never use timeGetTime on Windows XP! It quickly overflows after two or three hours.

Use QueryPerformanceCounter instead.

I'd imagine that using some basic overflow-checking code would avoid that problem, no? As in making sure the current time is always > than the previous time, and if not alter your math accordingly to account for overflowing. I do use timeGetTime for Chicken Little, and while my platform here is win98, everyone else involved on the project is running XP and we haven't had any timing issues yet. But I do have said overflow checks in place and stuff, so maybe that's why. Or maybe we've just been lucky... I'd like to know for sure.

Also, according to the MSDN, QueryPerformanceCounter can give unreliable results on multiprocessor systems unless you make sure you lock your process's thread to one CPU using SetThreadAffinityMask. Nothing's ever clear-cut easy these days.

- Air
- Hour 13 Studios

*Edit: Fix your profile, Air - it's not closing the href link.

[edited by - Jim Adams on September 16, 2002 2:48:16 PM]
Advertisement
Shoot i''m on a decent machine too, Athlon 1.1ghz with a geforce3 but i''m only running 98 also. I just think certain configurations have problems. I''m not going to worry about it too much because 1) There''s no need to unless I get a bunch of users email me and tell me they can''t play my game 2) i''m moving to blitz, and so it''s going to be a bit different. (I''m pretty sure if I want to I can find a way to use the high performance counters/timers in blitz, but i''ll have to learn how to do that)

Keith
*************************************Keith Weatherby IIhttp://twitter.com/Uhfgoodhttp://www.facebook.com/Uhfgoodhttp://www.youtube.com/Uhfgoodhttp://www.gamesafoot.comhttp://indieflux.com*************************************
quote:Original post by Origin
Never use timeGetTime on Windows XP! It quickly overflows after two or three hours.

Use QueryPerformanceCounter instead.


How many times do I have to correct people on this? There is no problem if you use the difference between two calls to TimeGetTime ! It even tells you that in the help files.

That''s two people today with that misconception (and the third person so far) that I''ve corrected and I''m sure I''ll see plenty more in future.

See here.

Oh, and the quote from win32.hlp again:

quote:Note that the value returned by the timeGetTime function is a DWORD value. The return value wraps around to 0 every 2^32 milliseconds, which is about 49.71 days.This can cause problems in code that directly uses the timeGetTime return value in computations, particularly where the value is used to control code execution. You should always use the difference between two timeGetTime return values in computations.


Don''t spread this misconception, please.

(P.S. Make sure to use TimeGetDevCaps/TimeBeginPeriod/TimeEndPeriod with NT-based systems if you are going to use TimeGetTime.)
It runs too fast on mine too. Judging by the feedback you''re getting, it''s probably necessary to rework your time-based movement. I''ve used timeGetTime in my own software but I had problems running on other systems. QueryPerformanceCounter is extremely accurate and gives 64-bit values. Plus, it''s very easy to use. You can use timeGetTime if you''d like but you''re shooting yourself in the foot. Good Luck =)

- Jay

"I have head-explody!!!" - NNY

Get Tranced!
Quit screwin' around! - Brock Samson
quote:Original post by Alimonster
Don''t spread this misconception, please.

Just speaking from experience. It seems that a lot of people have trouble with timeGetTime. Perhaps we are not implementing it correctly. Either way, QueryPerformanceCounter is straightforward and works for everything I''ve tested on and therefore I use it.

Uhfgood: BTW, I''m running Win2000 on a P4 1.4G 512MB with a GeForce 3.

- Jay

"I have head-explody!!!" - NNY

Get Tranced!
Quit screwin' around! - Brock Samson
Okay i''m kind of noticing a trend here, it seems that win2k
isn''t doing too well with timeGetTime and i''m using the difference between them, my only problem is that i''m timing my game objects individually instead of all based on a single timer.

Anyways, there''s too much crap in there to fix it... the only way is to rewrite my timing functions to use the high performance timers, and I still have yet to figure it out. I really only want ms timing right now anyways, if anyone can show me an EASY way to use the high performance counter/timers i''d be glad to change it.

Keith
*************************************Keith Weatherby IIhttp://twitter.com/Uhfgoodhttp://www.facebook.com/Uhfgoodhttp://www.youtube.com/Uhfgoodhttp://www.gamesafoot.comhttp://indieflux.com*************************************
Are you using timeGetDevCaps/timeBeginPeriod/timeEndPeriod? You need to do that on NT systems if you want it to be accurate. Something like the following:


    TIMECAPS devCaps;// init, done once at the start of the programmemset(&devCaps, 0, sizeof(TIMECAPS));timeGetDevCaps(&devCaps, sizeof(TIMECAPS));timeBeginPeriod(devCaps.wPeriodMin);// use timeGetTime// at end of program...timeEndPeriod(devCaps.wPeriodMin);     


I'm interested to know if this works, btw - I want to know whether it's a good fall back if a high performance counter isn't available.

The misconception I mentioned, btw, is that overflowing messes up the results - it doesn't if you only take the difference between two calls.

[edited by - Alimonster on September 16, 2002 4:03:33 PM]
It might be a few days before I actually do anything... I''ll need to learn how to use the high perf counters/timers and then i''ll have to write the code for NT (of course i''m not sure how to tell if a system is an NT system ) So that''s like alot of junk I have to learn.

Which I will learn it''s just i''ve not encountered the problem, so since this is the first time, I have yet to learn more about this timing stuff.

Keith
*************************************Keith Weatherby IIhttp://twitter.com/Uhfgoodhttp://www.facebook.com/Uhfgoodhttp://www.youtube.com/Uhfgoodhttp://www.gamesafoot.comhttp://indieflux.com*************************************
You can use the code above under any Windows system - it's just that it will only make a difference under Windows NT ones. Windows 9x ones won't change their behaviour.

Windows 9x's timeGetTime defaults to 1msec precision (which is good) but NT-based timeGetTime doesn't (I can't remember the exact value, maybe 5msecs?). However, you can change it. The code I showed there just says "OI! Use the minimum value you possibly can for timeGetTime!" Under 9x, that means no change in behaviour - the minimum will be 1msec anyway. However, it will let NT systems update at their best possible timer resolution for timeGetTime. I think...

You don't have to write OS specific code.

[edited by - Alimonster on September 16, 2002 5:39:05 PM]
Thanks for the help, it may take me a few days

Keith
*************************************Keith Weatherby IIhttp://twitter.com/Uhfgoodhttp://www.facebook.com/Uhfgoodhttp://www.youtube.com/Uhfgoodhttp://www.gamesafoot.comhttp://indieflux.com*************************************

This topic is closed to new replies.

Advertisement