z42
01-14-2008, 07:39 PM
Is there any functionality in ClanLib to retrieve a high-precision/resolution time value like it is available with the Windows API ::QueryPerformanceCounter()?
I searched the docs, forum and the code but couldn't find anything besides CL_System::get_time(). This functions implementation uses ::QueryPerformanceCounter() which makes good precision but limits the resolution by returning ms units only.
Furthermore CL_System::get_time() seems to have a multicore-issue that occassionally results in discontinuous movement of objects if you base the timing in your games frame loop on it. "Occassionally" means e.g. once every ~30s, some times more often and very noticable.
I could work around this by calling ::SetProcessAffinityMask( ::GetCurrentProcess(), 1 ) at the start of my game, but would loose platform-independence.
(See also:
http://msdn2.microsoft.com/en-us/library/bb173458(VS.85).aspx
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q274323 )
Last, I suggest increasing the precision of CL_System::sleep() which has a default precision of only ~10ms under Windows by calling Windows-API ::timeBeginPeriod( 1 ) at process start and ::timeEndPeriod( 1 ) at process end. Or at least provide an option to do so.
I searched the docs, forum and the code but couldn't find anything besides CL_System::get_time(). This functions implementation uses ::QueryPerformanceCounter() which makes good precision but limits the resolution by returning ms units only.
Furthermore CL_System::get_time() seems to have a multicore-issue that occassionally results in discontinuous movement of objects if you base the timing in your games frame loop on it. "Occassionally" means e.g. once every ~30s, some times more often and very noticable.
I could work around this by calling ::SetProcessAffinityMask( ::GetCurrentProcess(), 1 ) at the start of my game, but would loose platform-independence.
(See also:
http://msdn2.microsoft.com/en-us/library/bb173458(VS.85).aspx
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q274323 )
Last, I suggest increasing the precision of CL_System::sleep() which has a default precision of only ~10ms under Windows by calling Windows-API ::timeBeginPeriod( 1 ) at process start and ::timeEndPeriod( 1 ) at process end. Or at least provide an option to do so.