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