Skylicht Engine
Loading...
Searching...
No Matches
irrOS.h
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 IRRLICHT_API 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 IRRLICHT_API 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 IRRLICHT_API Randomizer
50 {
51 public:
52
54 static void reset(s32 value=0x0f0f0f0f);
55
57 static s32 rand();
58
60 static f32 frand();
61
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 IRRLICHT_API Timer
79 {
80 public:
81
83 static u32 getTime();
84
87
89 static void initTimer(bool usePerformanceTimer=true);
90
92 static void setTime(u32 time);
93
95 static void stopTimer();
96
98 static void startTimer();
99
101 static void setSpeed(f32 speed);
102
104 static f32 getSpeed();
105
107 static bool isStopped();
108
110 static void tick();
111
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
Interface for logging messages, warnings and errors.
Definition ILogger.h:39
Definition irrOS.h:21
Definition irrOS.h:34
Definition irrOS.h:50
static f32 frand()
generates a pseudo random number in the range 0..1
static s32 randMax()
get maxmimum number generated by rand()
static void reset(s32 value=0x0f0f0f0f)
resets the randomizer
static s32 rand()
generates a pseudo random number in the range 0..randMax()
Definition irrOS.h:79
static void tick()
makes the virtual timer update the time value based on the real time
static void startTimer()
starts the game timer
static f32 getSpeed()
gets the speed of the virtual timer
static u32 getRealTime()
returns the current real time in milliseconds
static bool isStopped()
returns if the timer currently is stopped
static ITimer::RealTimeDate getRealTimeAndDate()
get current time and date in calendar form
static void initTimer(bool usePerformanceTimer=true)
initializes the real timer
static u32 getTime()
returns the current time in milliseconds
static void setTime(u32 time)
sets the current virtual (game) time
static void setSpeed(f32 speed)
sets the speed of the virtual timer
static void stopTimer()
stops the virtual (game) timer
core::string< fschar_t > path
Type used for all file system related strings.
Definition path.h:17
Everything in the Irrlicht Engine can be found in this namespace.
Definition Skylicht.h:33
float f32
32 bit floating point variable.
Definition irrTypes.h:104
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58
signed short s16
16 bit signed variable.
Definition irrTypes.h:48
unsigned char u8
8 bit unsigned variable.
Definition irrTypes.h:18
char c8
8 bit character variable.
Definition irrTypes.h:31
ELOG_LEVEL
Definition ILogger.h:18
@ ELL_INFORMATION
Useful information to print. For example hardware infos or something started/stopped.
Definition ILogger.h:23
signed int s32
32 bit signed variable.
Definition irrTypes.h:66
unsigned short u16
16 bit unsigned variable.
Definition irrTypes.h:40
Definition ITimer.h:36