[ODE] Timer?

David McClurg dmcclurg at pandemicstudios.com.au
Mon Feb 10 15:43:01 2003


on win32, using timeGetTime() from the winmm.lib is the most common solution.  the best solution for win32 is QueryPerformanceCounter().  look at the BZFLAG sources.  it has good solutions for all platforms.

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/bzflag/bzflag/src/platform/WinPlatformFactory.cxx?rev=HEAD&content-type=text/vnd.viewcvs-markup
double					WinPlatformFactory::getClock() const
{
	if (qpcFrequency != 0.0) {
		LARGE_INTEGER now;
		QueryPerformanceCounter(&now);
		return qpcFrequency * (double)(now.QuadPart - qpcZero.QuadPart);
	}
	else {
		unsigned int now = (unsigned int)timeGetTime();
		return 1.0e-3 * (now - clockZero);
	}
}

-----Original Message-----
From: Amund Børsand [mailto:amund@c2i.net]
Sent: Tuesday, 11 February 2003 1:37 AM
To: ODE@q12.org
Subject: [ODE] Timer?



Does anyone know a high (enough) resolution timer in C? I am using ODE
with the MingW-compiler, and I'm trying to make it real-time by
inserting the actual time from the last frame to the current into dWorldStep(). 

The function I'm currently using, clock() from time.h, claims to have
1000 CLOCKS_PER_SEC, but every now and then my t0-t (t0 being the
previous clock() and t being the current) function returns 0. Not just
every now and then, actually, but probably five times per second, when
I'm running the simulation at about 30-40 fps I guess. Is there some
other counter that is more accurate?



-- 
Amund Børsand <amund@c2i.net>


_______________________________________________
ODE mailing list
ODE@q12.org
http://q12.org/mailman/listinfo/ode