From: Ben S. <bs...@vr...> - 2001-11-30 03:37:31
|
ok, here's how to get the current time (in ms) from the system clock: any win32 box: //----------------------------------------------- #include <sys/types.h> #include <sys/timeb.h> struct _timeb tv; _ftime( &tv ); double curTime = static_cast<double>( tv.time ) + ( static_cast<double>( tv.millitm ) / 1000.0 ); cout << "Current time is: "<<curTime<<endl; any unix flavor: //----------------------------------------------- #include <sys/time.h> struct timeval tv; gettimeofday( &tv, 0 ); double curTime = static_cast<double>( tv.tv_sec ) + ( static_cast<double>( tv.tv_usec ) / 1000000.0 ); cout << "Current time is: "<<curTime<<endl; //---------------------------------------------- i hope that gives you a good starting place. i basically ripped that code off of kevin meinert's StopWatch class which you can find at: http://cvs.sf.net/cgi-bin/viewcvs.cgi/isugamedev/tank/StopWatch.h?rev=1.7&content-type=text/vnd.viewcvs-markup lemme know if you have any questions. ----- Ben Scott President ISU Game Developers Club Treasurer ISU Ballroom Dance Company bs...@ia... |