diff options
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/os.cpp')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/os.cpp | 682 |
1 files changed, 341 insertions, 341 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/os.cpp b/libraries/irrlicht-1.8/source/Irrlicht/os.cpp index a801667..b9bf832 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/os.cpp +++ b/libraries/irrlicht-1.8/source/Irrlicht/os.cpp | |||
@@ -1,341 +1,341 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt | 1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt |
2 | // This file is part of the "Irrlicht Engine". | 2 | // This file is part of the "Irrlicht Engine". |
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | 3 | // For conditions of distribution and use, see copyright notice in irrlicht.h |
4 | 4 | ||
5 | #include "os.h" | 5 | #include "os.h" |
6 | #include "irrString.h" | 6 | #include "irrString.h" |
7 | #include "IrrCompileConfig.h" | 7 | #include "IrrCompileConfig.h" |
8 | #include "irrMath.h" | 8 | #include "irrMath.h" |
9 | 9 | ||
10 | #if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) | 10 | #if defined(_IRR_COMPILE_WITH_SDL_DEVICE_) |
11 | #include <SDL/SDL_endian.h> | 11 | #include <SDL/SDL_endian.h> |
12 | #define bswap_16(X) SDL_Swap16(X) | 12 | #define bswap_16(X) SDL_Swap16(X) |
13 | #define bswap_32(X) SDL_Swap32(X) | 13 | #define bswap_32(X) SDL_Swap32(X) |
14 | #elif defined(_IRR_WINDOWS_API_) && defined(_MSC_VER) && (_MSC_VER > 1298) | 14 | #elif defined(_IRR_WINDOWS_API_) && defined(_MSC_VER) && (_MSC_VER > 1298) |
15 | #include <stdlib.h> | 15 | #include <stdlib.h> |
16 | #define bswap_16(X) _byteswap_ushort(X) | 16 | #define bswap_16(X) _byteswap_ushort(X) |
17 | #define bswap_32(X) _byteswap_ulong(X) | 17 | #define bswap_32(X) _byteswap_ulong(X) |
18 | #if (_MSC_VER >= 1400) | 18 | #if (_MSC_VER >= 1400) |
19 | #define localtime _localtime_s | 19 | #define localtime _localtime_s |
20 | #endif | 20 | #endif |
21 | #elif defined(_IRR_OSX_PLATFORM_) | 21 | #elif defined(_IRR_OSX_PLATFORM_) |
22 | #include <libkern/OSByteOrder.h> | 22 | #include <libkern/OSByteOrder.h> |
23 | #define bswap_16(X) OSReadSwapInt16(&X,0) | 23 | #define bswap_16(X) OSReadSwapInt16(&X,0) |
24 | #define bswap_32(X) OSReadSwapInt32(&X,0) | 24 | #define bswap_32(X) OSReadSwapInt32(&X,0) |
25 | #elif defined(__FreeBSD__) || defined(__OpenBSD__) | 25 | #elif defined(__FreeBSD__) || defined(__OpenBSD__) |
26 | #include <sys/endian.h> | 26 | #include <sys/endian.h> |
27 | #define bswap_16(X) bswap16(X) | 27 | #define bswap_16(X) bswap16(X) |
28 | #define bswap_32(X) bswap32(X) | 28 | #define bswap_32(X) bswap32(X) |
29 | #elif !defined(_IRR_SOLARIS_PLATFORM_) && !defined(__PPC__) && !defined(_IRR_WINDOWS_API_) | 29 | #elif !defined(_IRR_SOLARIS_PLATFORM_) && !defined(__PPC__) && !defined(_IRR_WINDOWS_API_) |
30 | #include <byteswap.h> | 30 | #include <byteswap.h> |
31 | #else | 31 | #else |
32 | #define bswap_16(X) ((((X)&0xFF) << 8) | (((X)&0xFF00) >> 8)) | 32 | #define bswap_16(X) ((((X)&0xFF) << 8) | (((X)&0xFF00) >> 8)) |
33 | #define bswap_32(X) ( (((X)&0x000000FF)<<24) | (((X)&0xFF000000) >> 24) | (((X)&0x0000FF00) << 8) | (((X) &0x00FF0000) >> 8)) | 33 | #define bswap_32(X) ( (((X)&0x000000FF)<<24) | (((X)&0xFF000000) >> 24) | (((X)&0x0000FF00) << 8) | (((X) &0x00FF0000) >> 8)) |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | namespace irr | 36 | namespace irr |
37 | { | 37 | { |
38 | namespace os | 38 | namespace os |
39 | { | 39 | { |
40 | u16 Byteswap::byteswap(u16 num) {return bswap_16(num);} | 40 | u16 Byteswap::byteswap(u16 num) {return bswap_16(num);} |
41 | s16 Byteswap::byteswap(s16 num) {return bswap_16(num);} | 41 | s16 Byteswap::byteswap(s16 num) {return bswap_16(num);} |
42 | u32 Byteswap::byteswap(u32 num) {return bswap_32(num);} | 42 | u32 Byteswap::byteswap(u32 num) {return bswap_32(num);} |
43 | s32 Byteswap::byteswap(s32 num) {return bswap_32(num);} | 43 | s32 Byteswap::byteswap(s32 num) {return bswap_32(num);} |
44 | f32 Byteswap::byteswap(f32 num) {u32 tmp=IR(num); tmp=bswap_32(tmp); return (FR(tmp));} | 44 | f32 Byteswap::byteswap(f32 num) {u32 tmp=IR(num); tmp=bswap_32(tmp); return (FR(tmp));} |
45 | // prevent accidental byte swapping of chars | 45 | // prevent accidental byte swapping of chars |
46 | u8 Byteswap::byteswap(u8 num) {return num;} | 46 | u8 Byteswap::byteswap(u8 num) {return num;} |
47 | c8 Byteswap::byteswap(c8 num) {return num;} | 47 | c8 Byteswap::byteswap(c8 num) {return num;} |
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | #if defined(_IRR_WINDOWS_API_) | 51 | #if defined(_IRR_WINDOWS_API_) |
52 | // ---------------------------------------------------------------- | 52 | // ---------------------------------------------------------------- |
53 | // Windows specific functions | 53 | // Windows specific functions |
54 | // ---------------------------------------------------------------- | 54 | // ---------------------------------------------------------------- |
55 | 55 | ||
56 | #ifdef _IRR_XBOX_PLATFORM_ | 56 | #ifdef _IRR_XBOX_PLATFORM_ |
57 | #include <xtl.h> | 57 | #include <xtl.h> |
58 | #else | 58 | #else |
59 | #define WIN32_LEAN_AND_MEAN | 59 | #define WIN32_LEAN_AND_MEAN |
60 | #include <windows.h> | 60 | #include <windows.h> |
61 | #include <time.h> | 61 | #include <time.h> |
62 | #endif | 62 | #endif |
63 | 63 | ||
64 | namespace irr | 64 | namespace irr |
65 | { | 65 | { |
66 | namespace os | 66 | namespace os |
67 | { | 67 | { |
68 | //! prints a debuginfo string | 68 | //! prints a debuginfo string |
69 | void Printer::print(const c8* message) | 69 | void Printer::print(const c8* message) |
70 | { | 70 | { |
71 | #if defined (_WIN32_WCE ) | 71 | #if defined (_WIN32_WCE ) |
72 | core::stringw tmp(message); | 72 | core::stringw tmp(message); |
73 | tmp += L"\n"; | 73 | tmp += L"\n"; |
74 | OutputDebugStringW(tmp.c_str()); | 74 | OutputDebugStringW(tmp.c_str()); |
75 | #else | 75 | #else |
76 | core::stringc tmp(message); | 76 | core::stringc tmp(message); |
77 | tmp += "\n"; | 77 | tmp += "\n"; |
78 | OutputDebugStringA(tmp.c_str()); | 78 | OutputDebugStringA(tmp.c_str()); |
79 | printf("%s", tmp.c_str()); | 79 | printf("%s", tmp.c_str()); |
80 | #endif | 80 | #endif |
81 | } | 81 | } |
82 | 82 | ||
83 | static LARGE_INTEGER HighPerformanceFreq; | 83 | static LARGE_INTEGER HighPerformanceFreq; |
84 | static BOOL HighPerformanceTimerSupport = FALSE; | 84 | static BOOL HighPerformanceTimerSupport = FALSE; |
85 | static BOOL MultiCore = FALSE; | 85 | static BOOL MultiCore = FALSE; |
86 | 86 | ||
87 | void Timer::initTimer(bool usePerformanceTimer) | 87 | void Timer::initTimer(bool usePerformanceTimer) |
88 | { | 88 | { |
89 | #if !defined(_WIN32_WCE) && !defined (_IRR_XBOX_PLATFORM_) | 89 | #if !defined(_WIN32_WCE) && !defined (_IRR_XBOX_PLATFORM_) |
90 | // workaround for hires timer on multiple core systems, bios bugs result in bad hires timers. | 90 | // workaround for hires timer on multiple core systems, bios bugs result in bad hires timers. |
91 | SYSTEM_INFO sysinfo; | 91 | SYSTEM_INFO sysinfo; |
92 | GetSystemInfo(&sysinfo); | 92 | GetSystemInfo(&sysinfo); |
93 | MultiCore = (sysinfo.dwNumberOfProcessors > 1); | 93 | MultiCore = (sysinfo.dwNumberOfProcessors > 1); |
94 | #endif | 94 | #endif |
95 | if (usePerformanceTimer) | 95 | if (usePerformanceTimer) |
96 | HighPerformanceTimerSupport = QueryPerformanceFrequency(&HighPerformanceFreq); | 96 | HighPerformanceTimerSupport = QueryPerformanceFrequency(&HighPerformanceFreq); |
97 | else | 97 | else |
98 | HighPerformanceTimerSupport = FALSE; | 98 | HighPerformanceTimerSupport = FALSE; |
99 | initVirtualTimer(); | 99 | initVirtualTimer(); |
100 | } | 100 | } |
101 | 101 | ||
102 | u32 Timer::getRealTime() | 102 | u32 Timer::getRealTime() |
103 | { | 103 | { |
104 | if (HighPerformanceTimerSupport) | 104 | if (HighPerformanceTimerSupport) |
105 | { | 105 | { |
106 | #if !defined(_WIN32_WCE) && !defined (_IRR_XBOX_PLATFORM_) | 106 | #if !defined(_WIN32_WCE) && !defined (_IRR_XBOX_PLATFORM_) |
107 | // Avoid potential timing inaccuracies across multiple cores by | 107 | // Avoid potential timing inaccuracies across multiple cores by |
108 | // temporarily setting the affinity of this process to one core. | 108 | // temporarily setting the affinity of this process to one core. |
109 | DWORD_PTR affinityMask=0; | 109 | DWORD_PTR affinityMask=0; |
110 | if(MultiCore) | 110 | if(MultiCore) |
111 | affinityMask = SetThreadAffinityMask(GetCurrentThread(), 1); | 111 | affinityMask = SetThreadAffinityMask(GetCurrentThread(), 1); |
112 | #endif | 112 | #endif |
113 | LARGE_INTEGER nTime; | 113 | LARGE_INTEGER nTime; |
114 | BOOL queriedOK = QueryPerformanceCounter(&nTime); | 114 | BOOL queriedOK = QueryPerformanceCounter(&nTime); |
115 | 115 | ||
116 | #if !defined(_WIN32_WCE) && !defined (_IRR_XBOX_PLATFORM_) | 116 | #if !defined(_WIN32_WCE) && !defined (_IRR_XBOX_PLATFORM_) |
117 | // Restore the true affinity. | 117 | // Restore the true affinity. |
118 | if(MultiCore) | 118 | if(MultiCore) |
119 | (void)SetThreadAffinityMask(GetCurrentThread(), affinityMask); | 119 | (void)SetThreadAffinityMask(GetCurrentThread(), affinityMask); |
120 | #endif | 120 | #endif |
121 | if(queriedOK) | 121 | if(queriedOK) |
122 | return u32((nTime.QuadPart) * 1000 / HighPerformanceFreq.QuadPart); | 122 | return u32((nTime.QuadPart) * 1000 / HighPerformanceFreq.QuadPart); |
123 | 123 | ||
124 | } | 124 | } |
125 | 125 | ||
126 | return GetTickCount(); | 126 | return GetTickCount(); |
127 | } | 127 | } |
128 | 128 | ||
129 | } // end namespace os | 129 | } // end namespace os |
130 | 130 | ||
131 | 131 | ||
132 | #else | 132 | #else |
133 | 133 | ||
134 | // ---------------------------------------------------------------- | 134 | // ---------------------------------------------------------------- |
135 | // linux/ansi version | 135 | // linux/ansi version |
136 | // ---------------------------------------------------------------- | 136 | // ---------------------------------------------------------------- |
137 | 137 | ||
138 | #include <stdio.h> | 138 | #include <stdio.h> |
139 | #include <time.h> | 139 | #include <time.h> |
140 | #include <sys/time.h> | 140 | #include <sys/time.h> |
141 | 141 | ||
142 | namespace irr | 142 | namespace irr |
143 | { | 143 | { |
144 | namespace os | 144 | namespace os |
145 | { | 145 | { |
146 | 146 | ||
147 | //! prints a debuginfo string | 147 | //! prints a debuginfo string |
148 | void Printer::print(const c8* message) | 148 | void Printer::print(const c8* message) |
149 | { | 149 | { |
150 | printf("%s\n", message); | 150 | printf("%s\n", message); |
151 | } | 151 | } |
152 | 152 | ||
153 | void Timer::initTimer(bool usePerformanceTimer) | 153 | void Timer::initTimer(bool usePerformanceTimer) |
154 | { | 154 | { |
155 | initVirtualTimer(); | 155 | initVirtualTimer(); |
156 | } | 156 | } |
157 | 157 | ||
158 | u32 Timer::getRealTime() | 158 | u32 Timer::getRealTime() |
159 | { | 159 | { |
160 | timeval tv; | 160 | timeval tv; |
161 | gettimeofday(&tv, 0); | 161 | gettimeofday(&tv, 0); |
162 | return (u32)(tv.tv_sec * 1000) + (tv.tv_usec / 1000); | 162 | return (u32)(tv.tv_sec * 1000) + (tv.tv_usec / 1000); |
163 | } | 163 | } |
164 | } // end namespace os | 164 | } // end namespace os |
165 | 165 | ||
166 | #endif // end linux / windows | 166 | #endif // end linux / windows |
167 | 167 | ||
168 | namespace os | 168 | namespace os |
169 | { | 169 | { |
170 | // The platform independent implementation of the printer | 170 | // The platform independent implementation of the printer |
171 | ILogger* Printer::Logger = 0; | 171 | ILogger* Printer::Logger = 0; |
172 | 172 | ||
173 | void Printer::log(const c8* message, ELOG_LEVEL ll) | 173 | void Printer::log(const c8* message, ELOG_LEVEL ll) |
174 | { | 174 | { |
175 | if (Logger) | 175 | if (Logger) |
176 | Logger->log(message, ll); | 176 | Logger->log(message, ll); |
177 | } | 177 | } |
178 | 178 | ||
179 | void Printer::log(const wchar_t* message, ELOG_LEVEL ll) | 179 | void Printer::log(const wchar_t* message, ELOG_LEVEL ll) |
180 | { | 180 | { |
181 | if (Logger) | 181 | if (Logger) |
182 | Logger->log(message, ll); | 182 | Logger->log(message, ll); |
183 | } | 183 | } |
184 | 184 | ||
185 | void Printer::log(const c8* message, const c8* hint, ELOG_LEVEL ll) | 185 | void Printer::log(const c8* message, const c8* hint, ELOG_LEVEL ll) |
186 | { | 186 | { |
187 | if (Logger) | 187 | if (Logger) |
188 | Logger->log(message, hint, ll); | 188 | Logger->log(message, hint, ll); |
189 | } | 189 | } |
190 | 190 | ||
191 | void Printer::log(const c8* message, const io::path& hint, ELOG_LEVEL ll) | 191 | void Printer::log(const c8* message, const io::path& hint, ELOG_LEVEL ll) |
192 | { | 192 | { |
193 | if (Logger) | 193 | if (Logger) |
194 | Logger->log(message, hint.c_str(), ll); | 194 | Logger->log(message, hint.c_str(), ll); |
195 | } | 195 | } |
196 | 196 | ||
197 | // our Randomizer is not really os specific, so we | 197 | // our Randomizer is not really os specific, so we |
198 | // code one for all, which should work on every platform the same, | 198 | // code one for all, which should work on every platform the same, |
199 | // which is desireable. | 199 | // which is desireable. |
200 | 200 | ||
201 | s32 Randomizer::seed = 0x0f0f0f0f; | 201 | s32 Randomizer::seed = 0x0f0f0f0f; |
202 | 202 | ||
203 | //! generates a pseudo random number | 203 | //! generates a pseudo random number |
204 | s32 Randomizer::rand() | 204 | s32 Randomizer::rand() |
205 | { | 205 | { |
206 | // (a*seed)%m with Schrage's method | 206 | // (a*seed)%m with Schrage's method |
207 | seed = a * (seed%q) - r* (seed/q); | 207 | seed = a * (seed%q) - r* (seed/q); |
208 | if (seed<0) | 208 | if (seed<0) |
209 | seed += m; | 209 | seed += m; |
210 | 210 | ||
211 | return seed; | 211 | return seed; |
212 | } | 212 | } |
213 | 213 | ||
214 | //! generates a pseudo random number | 214 | //! generates a pseudo random number |
215 | f32 Randomizer::frand() | 215 | f32 Randomizer::frand() |
216 | { | 216 | { |
217 | return rand()*(1.f/rMax); | 217 | return rand()*(1.f/rMax); |
218 | } | 218 | } |
219 | 219 | ||
220 | s32 Randomizer::randMax() | 220 | s32 Randomizer::randMax() |
221 | { | 221 | { |
222 | return rMax; | 222 | return rMax; |
223 | } | 223 | } |
224 | 224 | ||
225 | //! resets the randomizer | 225 | //! resets the randomizer |
226 | void Randomizer::reset(s32 value) | 226 | void Randomizer::reset(s32 value) |
227 | { | 227 | { |
228 | seed = value; | 228 | seed = value; |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | // ------------------------------------------------------ | 232 | // ------------------------------------------------------ |
233 | // virtual timer implementation | 233 | // virtual timer implementation |
234 | 234 | ||
235 | f32 Timer::VirtualTimerSpeed = 1.0f; | 235 | f32 Timer::VirtualTimerSpeed = 1.0f; |
236 | s32 Timer::VirtualTimerStopCounter = 0; | 236 | s32 Timer::VirtualTimerStopCounter = 0; |
237 | u32 Timer::LastVirtualTime = 0; | 237 | u32 Timer::LastVirtualTime = 0; |
238 | u32 Timer::StartRealTime = 0; | 238 | u32 Timer::StartRealTime = 0; |
239 | u32 Timer::StaticTime = 0; | 239 | u32 Timer::StaticTime = 0; |
240 | 240 | ||
241 | //! Get real time and date in calendar form | 241 | //! Get real time and date in calendar form |
242 | ITimer::RealTimeDate Timer::getRealTimeAndDate() | 242 | ITimer::RealTimeDate Timer::getRealTimeAndDate() |
243 | { | 243 | { |
244 | time_t rawtime; | 244 | time_t rawtime; |
245 | time(&rawtime); | 245 | time(&rawtime); |
246 | 246 | ||
247 | struct tm * timeinfo; | 247 | struct tm * timeinfo; |
248 | timeinfo = localtime(&rawtime); | 248 | timeinfo = localtime(&rawtime); |
249 | 249 | ||
250 | ITimer::RealTimeDate date; | 250 | ITimer::RealTimeDate date; |
251 | date.Hour=(u32)timeinfo->tm_hour; | 251 | date.Hour=(u32)timeinfo->tm_hour; |
252 | date.Minute=(u32)timeinfo->tm_min; | 252 | date.Minute=(u32)timeinfo->tm_min; |
253 | date.Second=(u32)timeinfo->tm_sec; | 253 | date.Second=(u32)timeinfo->tm_sec; |
254 | date.Day=(u32)timeinfo->tm_mday; | 254 | date.Day=(u32)timeinfo->tm_mday; |
255 | date.Month=(u32)timeinfo->tm_mon+1; | 255 | date.Month=(u32)timeinfo->tm_mon+1; |
256 | date.Year=(u32)timeinfo->tm_year+1900; | 256 | date.Year=(u32)timeinfo->tm_year+1900; |
257 | date.Weekday=(ITimer::EWeekday)timeinfo->tm_wday; | 257 | date.Weekday=(ITimer::EWeekday)timeinfo->tm_wday; |
258 | date.Yearday=(u32)timeinfo->tm_yday+1; | 258 | date.Yearday=(u32)timeinfo->tm_yday+1; |
259 | date.IsDST=timeinfo->tm_isdst != 0; | 259 | date.IsDST=timeinfo->tm_isdst != 0; |
260 | return date; | 260 | return date; |
261 | } | 261 | } |
262 | 262 | ||
263 | //! returns current virtual time | 263 | //! returns current virtual time |
264 | u32 Timer::getTime() | 264 | u32 Timer::getTime() |
265 | { | 265 | { |
266 | if (isStopped()) | 266 | if (isStopped()) |
267 | return LastVirtualTime; | 267 | return LastVirtualTime; |
268 | 268 | ||
269 | return LastVirtualTime + (u32)((StaticTime - StartRealTime) * VirtualTimerSpeed); | 269 | return LastVirtualTime + (u32)((StaticTime - StartRealTime) * VirtualTimerSpeed); |
270 | } | 270 | } |
271 | 271 | ||
272 | //! ticks, advances the virtual timer | 272 | //! ticks, advances the virtual timer |
273 | void Timer::tick() | 273 | void Timer::tick() |
274 | { | 274 | { |
275 | StaticTime = getRealTime(); | 275 | StaticTime = getRealTime(); |
276 | } | 276 | } |
277 | 277 | ||
278 | //! sets the current virtual time | 278 | //! sets the current virtual time |
279 | void Timer::setTime(u32 time) | 279 | void Timer::setTime(u32 time) |
280 | { | 280 | { |
281 | StaticTime = getRealTime(); | 281 | StaticTime = getRealTime(); |
282 | LastVirtualTime = time; | 282 | LastVirtualTime = time; |
283 | StartRealTime = StaticTime; | 283 | StartRealTime = StaticTime; |
284 | } | 284 | } |
285 | 285 | ||
286 | //! stops the virtual timer | 286 | //! stops the virtual timer |
287 | void Timer::stopTimer() | 287 | void Timer::stopTimer() |
288 | { | 288 | { |
289 | if (!isStopped()) | 289 | if (!isStopped()) |
290 | { | 290 | { |
291 | // stop the virtual timer | 291 | // stop the virtual timer |
292 | LastVirtualTime = getTime(); | 292 | LastVirtualTime = getTime(); |
293 | } | 293 | } |
294 | 294 | ||
295 | --VirtualTimerStopCounter; | 295 | --VirtualTimerStopCounter; |
296 | } | 296 | } |
297 | 297 | ||
298 | //! starts the virtual timer | 298 | //! starts the virtual timer |
299 | void Timer::startTimer() | 299 | void Timer::startTimer() |
300 | { | 300 | { |
301 | ++VirtualTimerStopCounter; | 301 | ++VirtualTimerStopCounter; |
302 | 302 | ||
303 | if (!isStopped()) | 303 | if (!isStopped()) |
304 | { | 304 | { |
305 | // restart virtual timer | 305 | // restart virtual timer |
306 | setTime(LastVirtualTime); | 306 | setTime(LastVirtualTime); |
307 | } | 307 | } |
308 | } | 308 | } |
309 | 309 | ||
310 | //! sets the speed of the virtual timer | 310 | //! sets the speed of the virtual timer |
311 | void Timer::setSpeed(f32 speed) | 311 | void Timer::setSpeed(f32 speed) |
312 | { | 312 | { |
313 | setTime(getTime()); | 313 | setTime(getTime()); |
314 | 314 | ||
315 | VirtualTimerSpeed = speed; | 315 | VirtualTimerSpeed = speed; |
316 | if (VirtualTimerSpeed < 0.0f) | 316 | if (VirtualTimerSpeed < 0.0f) |
317 | VirtualTimerSpeed = 0.0f; | 317 | VirtualTimerSpeed = 0.0f; |
318 | } | 318 | } |
319 | 319 | ||
320 | //! gets the speed of the virtual timer | 320 | //! gets the speed of the virtual timer |
321 | f32 Timer::getSpeed() | 321 | f32 Timer::getSpeed() |
322 | { | 322 | { |
323 | return VirtualTimerSpeed; | 323 | return VirtualTimerSpeed; |
324 | } | 324 | } |
325 | 325 | ||
326 | //! returns if the timer currently is stopped | 326 | //! returns if the timer currently is stopped |
327 | bool Timer::isStopped() | 327 | bool Timer::isStopped() |
328 | { | 328 | { |
329 | return VirtualTimerStopCounter < 0; | 329 | return VirtualTimerStopCounter < 0; |
330 | } | 330 | } |
331 | 331 | ||
332 | void Timer::initVirtualTimer() | 332 | void Timer::initVirtualTimer() |
333 | { | 333 | { |
334 | StaticTime = getRealTime(); | 334 | StaticTime = getRealTime(); |
335 | StartRealTime = StaticTime; | 335 | StartRealTime = StaticTime; |
336 | } | 336 | } |
337 | 337 | ||
338 | } // end namespace os | 338 | } // end namespace os |
339 | } // end namespace irr | 339 | } // end namespace irr |
340 | 340 | ||
341 | 341 | ||