2 fegdk: FE Game Development Kit
3 Copyright (C) 2001-2008 Alexey "waker" Yakovenko
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 waker@users.sourceforge.net
32 static float processTime
;
35 initProcessTime (void)
38 processTime
= timeGetTime ()*0.001f
;
41 gettimeofday (&tv
, NULL
);
42 processTime
= tv
.tv_sec
+ tv
.tv_usec
* 0.000001;
50 return timeGetTime ()*0.001f
- processTime
;
53 float getProcessTime (void)
56 gettimeofday (&tv
, NULL
);
57 return tv
.tv_sec
+ tv
.tv_usec
* 0.000001- processTime
;
72 mStartTime
= getProcessTime ();
79 void timer::update (void)
82 mSysPrevTime
= mSysCurrentTime
;
83 mSysCurrentTime
= getProcessTime () - mStartTime
;
85 mPrevTime
= mCurrentTime
;
87 mCurrentTime
+= mSysCurrentTime
- mSysPrevTime
;
90 float timer::getTime (void) const
95 float timer::getTimePassed (void) const
97 return mCurrentTime
- mPrevTime
;
100 float timer::getSysTime (void) const
102 return mSysCurrentTime
;
105 float timer::getSysTimePassed () const
107 return mSysCurrentTime
- mSysPrevTime
;
110 void timer::pause (bool onoff
)
116 bool timer::isPaused (void) const