diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/os.h | 262 |
1 files changed, 131 insertions, 131 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/os.h b/libraries/irrlicht-1.8/source/Irrlicht/os.h index 07059ca..539f34b 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/os.h +++ b/libraries/irrlicht-1.8/source/Irrlicht/os.h | |||
@@ -1,131 +1,131 @@ | |||
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 | #ifndef __IRR_OS_H_INCLUDED__ | 5 | #ifndef __IRR_OS_H_INCLUDED__ |
6 | #define __IRR_OS_H_INCLUDED__ | 6 | #define __IRR_OS_H_INCLUDED__ |
7 | 7 | ||
8 | #include "IrrCompileConfig.h" // for endian check | 8 | #include "IrrCompileConfig.h" // for endian check |
9 | #include "irrTypes.h" | 9 | #include "irrTypes.h" |
10 | #include "irrString.h" | 10 | #include "irrString.h" |
11 | #include "path.h" | 11 | #include "path.h" |
12 | #include "ILogger.h" | 12 | #include "ILogger.h" |
13 | #include "ITimer.h" | 13 | #include "ITimer.h" |
14 | 14 | ||
15 | namespace irr | 15 | namespace irr |
16 | { | 16 | { |
17 | 17 | ||
18 | namespace os | 18 | namespace os |
19 | { | 19 | { |
20 | class Byteswap | 20 | class Byteswap |
21 | { | 21 | { |
22 | public: | 22 | public: |
23 | static u16 byteswap(u16 num); | 23 | static u16 byteswap(u16 num); |
24 | static s16 byteswap(s16 num); | 24 | static s16 byteswap(s16 num); |
25 | static u32 byteswap(u32 num); | 25 | static u32 byteswap(u32 num); |
26 | static s32 byteswap(s32 num); | 26 | static s32 byteswap(s32 num); |
27 | static f32 byteswap(f32 num); | 27 | static f32 byteswap(f32 num); |
28 | // prevent accidental swapping of chars | 28 | // prevent accidental swapping of chars |
29 | static u8 byteswap(u8 num); | 29 | static u8 byteswap(u8 num); |
30 | static c8 byteswap(c8 num); | 30 | static c8 byteswap(c8 num); |
31 | }; | 31 | }; |
32 | 32 | ||
33 | class Printer | 33 | class Printer |
34 | { | 34 | { |
35 | public: | 35 | public: |
36 | // prints out a string to the console out stdout or debug log or whatever | 36 | // prints out a string to the console out stdout or debug log or whatever |
37 | static void print(const c8* message); | 37 | static void print(const c8* message); |
38 | static void log(const c8* message, ELOG_LEVEL ll = ELL_INFORMATION); | 38 | static void log(const c8* message, ELOG_LEVEL ll = ELL_INFORMATION); |
39 | static void log(const wchar_t* message, ELOG_LEVEL ll = ELL_INFORMATION); | 39 | static void log(const wchar_t* message, ELOG_LEVEL ll = ELL_INFORMATION); |
40 | static void log(const c8* message, const c8* hint, ELOG_LEVEL ll = ELL_INFORMATION); | 40 | static void log(const c8* message, const c8* hint, ELOG_LEVEL ll = ELL_INFORMATION); |
41 | static void log(const c8* message, const io::path& hint, ELOG_LEVEL ll = ELL_INFORMATION); | 41 | static void log(const c8* message, const io::path& hint, ELOG_LEVEL ll = ELL_INFORMATION); |
42 | static ILogger* Logger; | 42 | static ILogger* Logger; |
43 | }; | 43 | }; |
44 | 44 | ||
45 | 45 | ||
46 | // mixed linear congruential generator (MLCG) | 46 | // mixed linear congruential generator (MLCG) |
47 | // numbers chosen according to L'Ecuyer, Commun. ACM 31 (1988) 742 | 47 | // numbers chosen according to L'Ecuyer, Commun. ACM 31 (1988) 742 |
48 | // period is somewhere around m-1 | 48 | // period is somewhere around m-1 |
49 | class Randomizer | 49 | class Randomizer |
50 | { | 50 | { |
51 | public: | 51 | public: |
52 | 52 | ||
53 | //! resets the randomizer | 53 | //! resets the randomizer |
54 | static void reset(s32 value=0x0f0f0f0f); | 54 | static void reset(s32 value=0x0f0f0f0f); |
55 | 55 | ||
56 | //! generates a pseudo random number in the range 0..randMax() | 56 | //! generates a pseudo random number in the range 0..randMax() |
57 | static s32 rand(); | 57 | static s32 rand(); |
58 | 58 | ||
59 | //! generates a pseudo random number in the range 0..1 | 59 | //! generates a pseudo random number in the range 0..1 |
60 | static f32 frand(); | 60 | static f32 frand(); |
61 | 61 | ||
62 | //! get maxmimum number generated by rand() | 62 | //! get maxmimum number generated by rand() |
63 | static s32 randMax(); | 63 | static s32 randMax(); |
64 | 64 | ||
65 | private: | 65 | private: |
66 | 66 | ||
67 | static s32 seed; | 67 | static s32 seed; |
68 | static const s32 m = 2147483399; // a non-Mersenne prime | 68 | static const s32 m = 2147483399; // a non-Mersenne prime |
69 | static const s32 a = 40692; // another spectral success story | 69 | static const s32 a = 40692; // another spectral success story |
70 | static const s32 q = m/a; | 70 | static const s32 q = m/a; |
71 | static const s32 r = m%a; // again less than q | 71 | static const s32 r = m%a; // again less than q |
72 | static const s32 rMax = m-1; | 72 | static const s32 rMax = m-1; |
73 | }; | 73 | }; |
74 | 74 | ||
75 | 75 | ||
76 | 76 | ||
77 | 77 | ||
78 | class Timer | 78 | class Timer |
79 | { | 79 | { |
80 | public: | 80 | public: |
81 | 81 | ||
82 | //! returns the current time in milliseconds | 82 | //! returns the current time in milliseconds |
83 | static u32 getTime(); | 83 | static u32 getTime(); |
84 | 84 | ||
85 | //! get current time and date in calendar form | 85 | //! get current time and date in calendar form |
86 | static ITimer::RealTimeDate getRealTimeAndDate(); | 86 | static ITimer::RealTimeDate getRealTimeAndDate(); |
87 | 87 | ||
88 | //! initializes the real timer | 88 | //! initializes the real timer |
89 | static void initTimer(bool usePerformanceTimer=true); | 89 | static void initTimer(bool usePerformanceTimer=true); |
90 | 90 | ||
91 | //! sets the current virtual (game) time | 91 | //! sets the current virtual (game) time |
92 | static void setTime(u32 time); | 92 | static void setTime(u32 time); |
93 | 93 | ||
94 | //! stops the virtual (game) timer | 94 | //! stops the virtual (game) timer |
95 | static void stopTimer(); | 95 | static void stopTimer(); |
96 | 96 | ||
97 | //! starts the game timer | 97 | //! starts the game timer |
98 | static void startTimer(); | 98 | static void startTimer(); |
99 | 99 | ||
100 | //! sets the speed of the virtual timer | 100 | //! sets the speed of the virtual timer |
101 | static void setSpeed(f32 speed); | 101 | static void setSpeed(f32 speed); |
102 | 102 | ||
103 | //! gets the speed of the virtual timer | 103 | //! gets the speed of the virtual timer |
104 | static f32 getSpeed(); | 104 | static f32 getSpeed(); |
105 | 105 | ||
106 | //! returns if the timer currently is stopped | 106 | //! returns if the timer currently is stopped |
107 | static bool isStopped(); | 107 | static bool isStopped(); |
108 | 108 | ||
109 | //! makes the virtual timer update the time value based on the real time | 109 | //! makes the virtual timer update the time value based on the real time |
110 | static void tick(); | 110 | static void tick(); |
111 | 111 | ||
112 | //! returns the current real time in milliseconds | 112 | //! returns the current real time in milliseconds |
113 | static u32 getRealTime(); | 113 | static u32 getRealTime(); |
114 | 114 | ||
115 | private: | 115 | private: |
116 | 116 | ||
117 | static void initVirtualTimer(); | 117 | static void initVirtualTimer(); |
118 | 118 | ||
119 | static f32 VirtualTimerSpeed; | 119 | static f32 VirtualTimerSpeed; |
120 | static s32 VirtualTimerStopCounter; | 120 | static s32 VirtualTimerStopCounter; |
121 | static u32 StartRealTime; | 121 | static u32 StartRealTime; |
122 | static u32 LastVirtualTime; | 122 | static u32 LastVirtualTime; |
123 | static u32 StaticTime; | 123 | static u32 StaticTime; |
124 | }; | 124 | }; |
125 | 125 | ||
126 | } // end namespace os | 126 | } // end namespace os |
127 | } // end namespace irr | 127 | } // end namespace irr |
128 | 128 | ||
129 | 129 | ||
130 | #endif | 130 | #endif |
131 | 131 | ||