diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceStub.cpp | 850 |
1 files changed, 425 insertions, 425 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceStub.cpp b/libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceStub.cpp index ce5fc7d..c419d90 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceStub.cpp +++ b/libraries/irrlicht-1.8/source/Irrlicht/CIrrDeviceStub.cpp | |||
@@ -1,425 +1,425 @@ | |||
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 "CIrrDeviceStub.h" | 5 | #include "CIrrDeviceStub.h" |
6 | #include "ISceneManager.h" | 6 | #include "ISceneManager.h" |
7 | #include "IEventReceiver.h" | 7 | #include "IEventReceiver.h" |
8 | #include "IFileSystem.h" | 8 | #include "IFileSystem.h" |
9 | #include "IGUIEnvironment.h" | 9 | #include "IGUIEnvironment.h" |
10 | #include "os.h" | 10 | #include "os.h" |
11 | #include "IrrCompileConfig.h" | 11 | #include "IrrCompileConfig.h" |
12 | #include "CTimer.h" | 12 | #include "CTimer.h" |
13 | #include "CLogger.h" | 13 | #include "CLogger.h" |
14 | #include "irrString.h" | 14 | #include "irrString.h" |
15 | #include "IRandomizer.h" | 15 | #include "IRandomizer.h" |
16 | 16 | ||
17 | namespace irr | 17 | namespace irr |
18 | { | 18 | { |
19 | //! constructor | 19 | //! constructor |
20 | CIrrDeviceStub::CIrrDeviceStub(const SIrrlichtCreationParameters& params) | 20 | CIrrDeviceStub::CIrrDeviceStub(const SIrrlichtCreationParameters& params) |
21 | : IrrlichtDevice(), VideoDriver(0), GUIEnvironment(0), SceneManager(0), | 21 | : IrrlichtDevice(), VideoDriver(0), GUIEnvironment(0), SceneManager(0), |
22 | Timer(0), CursorControl(0), UserReceiver(params.EventReceiver), Logger(0), Operator(0), | 22 | Timer(0), CursorControl(0), UserReceiver(params.EventReceiver), Logger(0), Operator(0), |
23 | Randomizer(0), FileSystem(0), InputReceivingSceneManager(0), CreationParams(params), | 23 | Randomizer(0), FileSystem(0), InputReceivingSceneManager(0), CreationParams(params), |
24 | Close(false) | 24 | Close(false) |
25 | { | 25 | { |
26 | Timer = new CTimer(params.UsePerformanceTimer); | 26 | Timer = new CTimer(params.UsePerformanceTimer); |
27 | if (os::Printer::Logger) | 27 | if (os::Printer::Logger) |
28 | { | 28 | { |
29 | os::Printer::Logger->grab(); | 29 | os::Printer::Logger->grab(); |
30 | Logger = (CLogger*)os::Printer::Logger; | 30 | Logger = (CLogger*)os::Printer::Logger; |
31 | Logger->setReceiver(UserReceiver); | 31 | Logger->setReceiver(UserReceiver); |
32 | } | 32 | } |
33 | else | 33 | else |
34 | { | 34 | { |
35 | Logger = new CLogger(UserReceiver); | 35 | Logger = new CLogger(UserReceiver); |
36 | os::Printer::Logger = Logger; | 36 | os::Printer::Logger = Logger; |
37 | } | 37 | } |
38 | Logger->setLogLevel(CreationParams.LoggingLevel); | 38 | Logger->setLogLevel(CreationParams.LoggingLevel); |
39 | 39 | ||
40 | os::Printer::Logger = Logger; | 40 | os::Printer::Logger = Logger; |
41 | Randomizer = createDefaultRandomizer(); | 41 | Randomizer = createDefaultRandomizer(); |
42 | 42 | ||
43 | FileSystem = io::createFileSystem(); | 43 | FileSystem = io::createFileSystem(); |
44 | core::stringc s = "Irrlicht Engine version "; | 44 | core::stringc s = "Irrlicht Engine version "; |
45 | s.append(getVersion()); | 45 | s.append(getVersion()); |
46 | os::Printer::log(s.c_str(), ELL_INFORMATION); | 46 | os::Printer::log(s.c_str(), ELL_INFORMATION); |
47 | 47 | ||
48 | checkVersion(params.SDK_version_do_not_use); | 48 | checkVersion(params.SDK_version_do_not_use); |
49 | } | 49 | } |
50 | 50 | ||
51 | 51 | ||
52 | CIrrDeviceStub::~CIrrDeviceStub() | 52 | CIrrDeviceStub::~CIrrDeviceStub() |
53 | { | 53 | { |
54 | FileSystem->drop(); | 54 | FileSystem->drop(); |
55 | 55 | ||
56 | if (GUIEnvironment) | 56 | if (GUIEnvironment) |
57 | GUIEnvironment->drop(); | 57 | GUIEnvironment->drop(); |
58 | 58 | ||
59 | if (VideoDriver) | 59 | if (VideoDriver) |
60 | VideoDriver->drop(); | 60 | VideoDriver->drop(); |
61 | 61 | ||
62 | if (SceneManager) | 62 | if (SceneManager) |
63 | SceneManager->drop(); | 63 | SceneManager->drop(); |
64 | 64 | ||
65 | if (InputReceivingSceneManager) | 65 | if (InputReceivingSceneManager) |
66 | InputReceivingSceneManager->drop(); | 66 | InputReceivingSceneManager->drop(); |
67 | 67 | ||
68 | if (CursorControl) | 68 | if (CursorControl) |
69 | CursorControl->drop(); | 69 | CursorControl->drop(); |
70 | 70 | ||
71 | if (Operator) | 71 | if (Operator) |
72 | Operator->drop(); | 72 | Operator->drop(); |
73 | 73 | ||
74 | if (Randomizer) | 74 | if (Randomizer) |
75 | Randomizer->drop(); | 75 | Randomizer->drop(); |
76 | 76 | ||
77 | CursorControl = 0; | 77 | CursorControl = 0; |
78 | 78 | ||
79 | if (Timer) | 79 | if (Timer) |
80 | Timer->drop(); | 80 | Timer->drop(); |
81 | 81 | ||
82 | if (Logger->drop()) | 82 | if (Logger->drop()) |
83 | os::Printer::Logger = 0; | 83 | os::Printer::Logger = 0; |
84 | } | 84 | } |
85 | 85 | ||
86 | 86 | ||
87 | void CIrrDeviceStub::createGUIAndScene() | 87 | void CIrrDeviceStub::createGUIAndScene() |
88 | { | 88 | { |
89 | #ifdef _IRR_COMPILE_WITH_GUI_ | 89 | #ifdef _IRR_COMPILE_WITH_GUI_ |
90 | // create gui environment | 90 | // create gui environment |
91 | GUIEnvironment = gui::createGUIEnvironment(FileSystem, VideoDriver, Operator); | 91 | GUIEnvironment = gui::createGUIEnvironment(FileSystem, VideoDriver, Operator); |
92 | #endif | 92 | #endif |
93 | 93 | ||
94 | // create Scene manager | 94 | // create Scene manager |
95 | SceneManager = scene::createSceneManager(VideoDriver, FileSystem, CursorControl, GUIEnvironment); | 95 | SceneManager = scene::createSceneManager(VideoDriver, FileSystem, CursorControl, GUIEnvironment); |
96 | 96 | ||
97 | setEventReceiver(UserReceiver); | 97 | setEventReceiver(UserReceiver); |
98 | } | 98 | } |
99 | 99 | ||
100 | 100 | ||
101 | //! returns the video driver | 101 | //! returns the video driver |
102 | video::IVideoDriver* CIrrDeviceStub::getVideoDriver() | 102 | video::IVideoDriver* CIrrDeviceStub::getVideoDriver() |
103 | { | 103 | { |
104 | return VideoDriver; | 104 | return VideoDriver; |
105 | } | 105 | } |
106 | 106 | ||
107 | 107 | ||
108 | 108 | ||
109 | //! return file system | 109 | //! return file system |
110 | io::IFileSystem* CIrrDeviceStub::getFileSystem() | 110 | io::IFileSystem* CIrrDeviceStub::getFileSystem() |
111 | { | 111 | { |
112 | return FileSystem; | 112 | return FileSystem; |
113 | } | 113 | } |
114 | 114 | ||
115 | 115 | ||
116 | 116 | ||
117 | //! returns the gui environment | 117 | //! returns the gui environment |
118 | gui::IGUIEnvironment* CIrrDeviceStub::getGUIEnvironment() | 118 | gui::IGUIEnvironment* CIrrDeviceStub::getGUIEnvironment() |
119 | { | 119 | { |
120 | return GUIEnvironment; | 120 | return GUIEnvironment; |
121 | } | 121 | } |
122 | 122 | ||
123 | 123 | ||
124 | 124 | ||
125 | //! returns the scene manager | 125 | //! returns the scene manager |
126 | scene::ISceneManager* CIrrDeviceStub::getSceneManager() | 126 | scene::ISceneManager* CIrrDeviceStub::getSceneManager() |
127 | { | 127 | { |
128 | return SceneManager; | 128 | return SceneManager; |
129 | } | 129 | } |
130 | 130 | ||
131 | 131 | ||
132 | //! \return Returns a pointer to the ITimer object. With it the | 132 | //! \return Returns a pointer to the ITimer object. With it the |
133 | //! current Time can be received. | 133 | //! current Time can be received. |
134 | ITimer* CIrrDeviceStub::getTimer() | 134 | ITimer* CIrrDeviceStub::getTimer() |
135 | { | 135 | { |
136 | return Timer; | 136 | return Timer; |
137 | } | 137 | } |
138 | 138 | ||
139 | 139 | ||
140 | //! Returns the version of the engine. | 140 | //! Returns the version of the engine. |
141 | const char* CIrrDeviceStub::getVersion() const | 141 | const char* CIrrDeviceStub::getVersion() const |
142 | { | 142 | { |
143 | return IRRLICHT_SDK_VERSION; | 143 | return IRRLICHT_SDK_VERSION; |
144 | } | 144 | } |
145 | 145 | ||
146 | //! \return Returns a pointer to the mouse cursor control interface. | 146 | //! \return Returns a pointer to the mouse cursor control interface. |
147 | gui::ICursorControl* CIrrDeviceStub::getCursorControl() | 147 | gui::ICursorControl* CIrrDeviceStub::getCursorControl() |
148 | { | 148 | { |
149 | return CursorControl; | 149 | return CursorControl; |
150 | } | 150 | } |
151 | 151 | ||
152 | 152 | ||
153 | //! \return Returns a pointer to a list with all video modes supported | 153 | //! \return Returns a pointer to a list with all video modes supported |
154 | //! by the gfx adapter. | 154 | //! by the gfx adapter. |
155 | video::IVideoModeList* CIrrDeviceStub::getVideoModeList() | 155 | video::IVideoModeList* CIrrDeviceStub::getVideoModeList() |
156 | { | 156 | { |
157 | return &VideoModeList; | 157 | return &VideoModeList; |
158 | } | 158 | } |
159 | 159 | ||
160 | 160 | ||
161 | //! checks version of sdk and prints warning if there might be a problem | 161 | //! checks version of sdk and prints warning if there might be a problem |
162 | bool CIrrDeviceStub::checkVersion(const char* version) | 162 | bool CIrrDeviceStub::checkVersion(const char* version) |
163 | { | 163 | { |
164 | if (strcmp(getVersion(), version)) | 164 | if (strcmp(getVersion(), version)) |
165 | { | 165 | { |
166 | core::stringc w; | 166 | core::stringc w; |
167 | w = "Warning: The library version of the Irrlicht Engine ("; | 167 | w = "Warning: The library version of the Irrlicht Engine ("; |
168 | w += getVersion(); | 168 | w += getVersion(); |
169 | w += ") does not match the version the application was compiled with ("; | 169 | w += ") does not match the version the application was compiled with ("; |
170 | w += version; | 170 | w += version; |
171 | w += "). This may cause problems."; | 171 | w += "). This may cause problems."; |
172 | os::Printer::log(w.c_str(), ELL_WARNING); | 172 | os::Printer::log(w.c_str(), ELL_WARNING); |
173 | _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; | 173 | _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; |
174 | return false; | 174 | return false; |
175 | } | 175 | } |
176 | 176 | ||
177 | return true; | 177 | return true; |
178 | } | 178 | } |
179 | 179 | ||
180 | 180 | ||
181 | //! Compares to the last call of this function to return double and triple clicks. | 181 | //! Compares to the last call of this function to return double and triple clicks. |
182 | u32 CIrrDeviceStub::checkSuccessiveClicks(s32 mouseX, s32 mouseY, EMOUSE_INPUT_EVENT inputEvent ) | 182 | u32 CIrrDeviceStub::checkSuccessiveClicks(s32 mouseX, s32 mouseY, EMOUSE_INPUT_EVENT inputEvent ) |
183 | { | 183 | { |
184 | const s32 MAX_MOUSEMOVE = 3; | 184 | const s32 MAX_MOUSEMOVE = 3; |
185 | 185 | ||
186 | irr::u32 clickTime = getTimer()->getRealTime(); | 186 | irr::u32 clickTime = getTimer()->getRealTime(); |
187 | 187 | ||
188 | if ( (clickTime-MouseMultiClicks.LastClickTime) < MouseMultiClicks.DoubleClickTime | 188 | if ( (clickTime-MouseMultiClicks.LastClickTime) < MouseMultiClicks.DoubleClickTime |
189 | && core::abs_(MouseMultiClicks.LastClick.X - mouseX ) <= MAX_MOUSEMOVE | 189 | && core::abs_(MouseMultiClicks.LastClick.X - mouseX ) <= MAX_MOUSEMOVE |
190 | && core::abs_(MouseMultiClicks.LastClick.Y - mouseY ) <= MAX_MOUSEMOVE | 190 | && core::abs_(MouseMultiClicks.LastClick.Y - mouseY ) <= MAX_MOUSEMOVE |
191 | && MouseMultiClicks.CountSuccessiveClicks < 3 | 191 | && MouseMultiClicks.CountSuccessiveClicks < 3 |
192 | && MouseMultiClicks.LastMouseInputEvent == inputEvent | 192 | && MouseMultiClicks.LastMouseInputEvent == inputEvent |
193 | ) | 193 | ) |
194 | { | 194 | { |
195 | ++MouseMultiClicks.CountSuccessiveClicks; | 195 | ++MouseMultiClicks.CountSuccessiveClicks; |
196 | } | 196 | } |
197 | else | 197 | else |
198 | { | 198 | { |
199 | MouseMultiClicks.CountSuccessiveClicks = 1; | 199 | MouseMultiClicks.CountSuccessiveClicks = 1; |
200 | } | 200 | } |
201 | 201 | ||
202 | MouseMultiClicks.LastMouseInputEvent = inputEvent; | 202 | MouseMultiClicks.LastMouseInputEvent = inputEvent; |
203 | MouseMultiClicks.LastClickTime = clickTime; | 203 | MouseMultiClicks.LastClickTime = clickTime; |
204 | MouseMultiClicks.LastClick.X = mouseX; | 204 | MouseMultiClicks.LastClick.X = mouseX; |
205 | MouseMultiClicks.LastClick.Y = mouseY; | 205 | MouseMultiClicks.LastClick.Y = mouseY; |
206 | 206 | ||
207 | return MouseMultiClicks.CountSuccessiveClicks; | 207 | return MouseMultiClicks.CountSuccessiveClicks; |
208 | } | 208 | } |
209 | 209 | ||
210 | 210 | ||
211 | //! send the event to the right receiver | 211 | //! send the event to the right receiver |
212 | bool CIrrDeviceStub::postEventFromUser(const SEvent& event) | 212 | bool CIrrDeviceStub::postEventFromUser(const SEvent& event) |
213 | { | 213 | { |
214 | bool absorbed = false; | 214 | bool absorbed = false; |
215 | 215 | ||
216 | if (UserReceiver) | 216 | if (UserReceiver) |
217 | absorbed = UserReceiver->OnEvent(event); | 217 | absorbed = UserReceiver->OnEvent(event); |
218 | 218 | ||
219 | if (!absorbed && GUIEnvironment) | 219 | if (!absorbed && GUIEnvironment) |
220 | absorbed = GUIEnvironment->postEventFromUser(event); | 220 | absorbed = GUIEnvironment->postEventFromUser(event); |
221 | 221 | ||
222 | scene::ISceneManager* inputReceiver = InputReceivingSceneManager; | 222 | scene::ISceneManager* inputReceiver = InputReceivingSceneManager; |
223 | if (!inputReceiver) | 223 | if (!inputReceiver) |
224 | inputReceiver = SceneManager; | 224 | inputReceiver = SceneManager; |
225 | 225 | ||
226 | if (!absorbed && inputReceiver) | 226 | if (!absorbed && inputReceiver) |
227 | absorbed = inputReceiver->postEventFromUser(event); | 227 | absorbed = inputReceiver->postEventFromUser(event); |
228 | 228 | ||
229 | _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; | 229 | _IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX; |
230 | return absorbed; | 230 | return absorbed; |
231 | } | 231 | } |
232 | 232 | ||
233 | 233 | ||
234 | //! Sets a new event receiver to receive events | 234 | //! Sets a new event receiver to receive events |
235 | void CIrrDeviceStub::setEventReceiver(IEventReceiver* receiver) | 235 | void CIrrDeviceStub::setEventReceiver(IEventReceiver* receiver) |
236 | { | 236 | { |
237 | UserReceiver = receiver; | 237 | UserReceiver = receiver; |
238 | Logger->setReceiver(receiver); | 238 | Logger->setReceiver(receiver); |
239 | if (GUIEnvironment) | 239 | if (GUIEnvironment) |
240 | GUIEnvironment->setUserEventReceiver(receiver); | 240 | GUIEnvironment->setUserEventReceiver(receiver); |
241 | } | 241 | } |
242 | 242 | ||
243 | 243 | ||
244 | //! Returns poinhter to the current event receiver. Returns 0 if there is none. | 244 | //! Returns poinhter to the current event receiver. Returns 0 if there is none. |
245 | IEventReceiver* CIrrDeviceStub::getEventReceiver() | 245 | IEventReceiver* CIrrDeviceStub::getEventReceiver() |
246 | { | 246 | { |
247 | return UserReceiver; | 247 | return UserReceiver; |
248 | } | 248 | } |
249 | 249 | ||
250 | 250 | ||
251 | //! \return Returns a pointer to the logger. | 251 | //! \return Returns a pointer to the logger. |
252 | ILogger* CIrrDeviceStub::getLogger() | 252 | ILogger* CIrrDeviceStub::getLogger() |
253 | { | 253 | { |
254 | return Logger; | 254 | return Logger; |
255 | } | 255 | } |
256 | 256 | ||
257 | 257 | ||
258 | //! Returns the operation system opertator object. | 258 | //! Returns the operation system opertator object. |
259 | IOSOperator* CIrrDeviceStub::getOSOperator() | 259 | IOSOperator* CIrrDeviceStub::getOSOperator() |
260 | { | 260 | { |
261 | return Operator; | 261 | return Operator; |
262 | } | 262 | } |
263 | 263 | ||
264 | 264 | ||
265 | //! Provides access to the engine's currently set randomizer. | 265 | //! Provides access to the engine's currently set randomizer. |
266 | IRandomizer* CIrrDeviceStub::getRandomizer() const | 266 | IRandomizer* CIrrDeviceStub::getRandomizer() const |
267 | { | 267 | { |
268 | return Randomizer; | 268 | return Randomizer; |
269 | } | 269 | } |
270 | 270 | ||
271 | //! Sets a new randomizer. | 271 | //! Sets a new randomizer. |
272 | void CIrrDeviceStub::setRandomizer(IRandomizer* r) | 272 | void CIrrDeviceStub::setRandomizer(IRandomizer* r) |
273 | { | 273 | { |
274 | if (r!=Randomizer) | 274 | if (r!=Randomizer) |
275 | { | 275 | { |
276 | if (Randomizer) | 276 | if (Randomizer) |
277 | Randomizer->drop(); | 277 | Randomizer->drop(); |
278 | Randomizer=r; | 278 | Randomizer=r; |
279 | if (Randomizer) | 279 | if (Randomizer) |
280 | Randomizer->grab(); | 280 | Randomizer->grab(); |
281 | } | 281 | } |
282 | } | 282 | } |
283 | 283 | ||
284 | namespace | 284 | namespace |
285 | { | 285 | { |
286 | struct SDefaultRandomizer : public IRandomizer | 286 | struct SDefaultRandomizer : public IRandomizer |
287 | { | 287 | { |
288 | virtual void reset(s32 value=0x0f0f0f0f) | 288 | virtual void reset(s32 value=0x0f0f0f0f) |
289 | { | 289 | { |
290 | os::Randomizer::reset(value); | 290 | os::Randomizer::reset(value); |
291 | } | 291 | } |
292 | 292 | ||
293 | virtual s32 rand() const | 293 | virtual s32 rand() const |
294 | { | 294 | { |
295 | return os::Randomizer::rand(); | 295 | return os::Randomizer::rand(); |
296 | } | 296 | } |
297 | 297 | ||
298 | virtual f32 frand() const | 298 | virtual f32 frand() const |
299 | { | 299 | { |
300 | return os::Randomizer::frand(); | 300 | return os::Randomizer::frand(); |
301 | } | 301 | } |
302 | 302 | ||
303 | virtual s32 randMax() const | 303 | virtual s32 randMax() const |
304 | { | 304 | { |
305 | return os::Randomizer::randMax(); | 305 | return os::Randomizer::randMax(); |
306 | } | 306 | } |
307 | }; | 307 | }; |
308 | } | 308 | } |
309 | 309 | ||
310 | //! Creates a new default randomizer. | 310 | //! Creates a new default randomizer. |
311 | IRandomizer* CIrrDeviceStub::createDefaultRandomizer() const | 311 | IRandomizer* CIrrDeviceStub::createDefaultRandomizer() const |
312 | { | 312 | { |
313 | IRandomizer* r = new SDefaultRandomizer(); | 313 | IRandomizer* r = new SDefaultRandomizer(); |
314 | if (r) | 314 | if (r) |
315 | r->reset(); | 315 | r->reset(); |
316 | return r; | 316 | return r; |
317 | } | 317 | } |
318 | 318 | ||
319 | 319 | ||
320 | //! Sets the input receiving scene manager. | 320 | //! Sets the input receiving scene manager. |
321 | void CIrrDeviceStub::setInputReceivingSceneManager(scene::ISceneManager* sceneManager) | 321 | void CIrrDeviceStub::setInputReceivingSceneManager(scene::ISceneManager* sceneManager) |
322 | { | 322 | { |
323 | if (sceneManager) | 323 | if (sceneManager) |
324 | sceneManager->grab(); | 324 | sceneManager->grab(); |
325 | if (InputReceivingSceneManager) | 325 | if (InputReceivingSceneManager) |
326 | InputReceivingSceneManager->drop(); | 326 | InputReceivingSceneManager->drop(); |
327 | 327 | ||
328 | InputReceivingSceneManager = sceneManager; | 328 | InputReceivingSceneManager = sceneManager; |
329 | } | 329 | } |
330 | 330 | ||
331 | 331 | ||
332 | //! Checks if the window is running in fullscreen mode | 332 | //! Checks if the window is running in fullscreen mode |
333 | bool CIrrDeviceStub::isFullscreen() const | 333 | bool CIrrDeviceStub::isFullscreen() const |
334 | { | 334 | { |
335 | return CreationParams.Fullscreen; | 335 | return CreationParams.Fullscreen; |
336 | } | 336 | } |
337 | 337 | ||
338 | 338 | ||
339 | //! returns color format | 339 | //! returns color format |
340 | video::ECOLOR_FORMAT CIrrDeviceStub::getColorFormat() const | 340 | video::ECOLOR_FORMAT CIrrDeviceStub::getColorFormat() const |
341 | { | 341 | { |
342 | return video::ECF_R5G6B5; | 342 | return video::ECF_R5G6B5; |
343 | } | 343 | } |
344 | 344 | ||
345 | //! No-op in this implementation | 345 | //! No-op in this implementation |
346 | bool CIrrDeviceStub::activateJoysticks(core::array<SJoystickInfo> & joystickInfo) | 346 | bool CIrrDeviceStub::activateJoysticks(core::array<SJoystickInfo> & joystickInfo) |
347 | { | 347 | { |
348 | return false; | 348 | return false; |
349 | } | 349 | } |
350 | 350 | ||
351 | /*! | 351 | /*! |
352 | */ | 352 | */ |
353 | void CIrrDeviceStub::calculateGammaRamp ( u16 *ramp, f32 gamma, f32 relativebrightness, f32 relativecontrast ) | 353 | void CIrrDeviceStub::calculateGammaRamp ( u16 *ramp, f32 gamma, f32 relativebrightness, f32 relativecontrast ) |
354 | { | 354 | { |
355 | s32 i; | 355 | s32 i; |
356 | s32 value; | 356 | s32 value; |
357 | s32 rbright = (s32) ( relativebrightness * (65535.f / 4 ) ); | 357 | s32 rbright = (s32) ( relativebrightness * (65535.f / 4 ) ); |
358 | f32 rcontrast = 1.f / (255.f - ( relativecontrast * 127.5f ) ); | 358 | f32 rcontrast = 1.f / (255.f - ( relativecontrast * 127.5f ) ); |
359 | 359 | ||
360 | gamma = gamma > 0.f ? 1.0f / gamma : 0.f; | 360 | gamma = gamma > 0.f ? 1.0f / gamma : 0.f; |
361 | 361 | ||
362 | for ( i = 0; i < 256; ++i ) | 362 | for ( i = 0; i < 256; ++i ) |
363 | { | 363 | { |
364 | value = (s32)(pow( rcontrast * i, gamma)*65535.f + 0.5f ); | 364 | value = (s32)(pow( rcontrast * i, gamma)*65535.f + 0.5f ); |
365 | ramp[i] = (u16) core::s32_clamp ( value + rbright, 0, 65535 ); | 365 | ramp[i] = (u16) core::s32_clamp ( value + rbright, 0, 65535 ); |
366 | } | 366 | } |
367 | 367 | ||
368 | } | 368 | } |
369 | 369 | ||
370 | void CIrrDeviceStub::calculateGammaFromRamp ( f32 &gamma, const u16 *ramp ) | 370 | void CIrrDeviceStub::calculateGammaFromRamp ( f32 &gamma, const u16 *ramp ) |
371 | { | 371 | { |
372 | /* The following is adapted from a post by Garrett Bass on OpenGL | 372 | /* The following is adapted from a post by Garrett Bass on OpenGL |
373 | Gamedev list, March 4, 2000. | 373 | Gamedev list, March 4, 2000. |
374 | */ | 374 | */ |
375 | f32 sum = 0.0; | 375 | f32 sum = 0.0; |
376 | s32 i, count = 0; | 376 | s32 i, count = 0; |
377 | 377 | ||
378 | gamma = 1.0; | 378 | gamma = 1.0; |
379 | for ( i = 1; i < 256; ++i ) { | 379 | for ( i = 1; i < 256; ++i ) { |
380 | if ( (ramp[i] != 0) && (ramp[i] != 65535) ) { | 380 | if ( (ramp[i] != 0) && (ramp[i] != 65535) ) { |
381 | f32 B = (f32)i / 256.f; | 381 | f32 B = (f32)i / 256.f; |
382 | f32 A = ramp[i] / 65535.f; | 382 | f32 A = ramp[i] / 65535.f; |
383 | sum += (f32) ( logf(A) / logf(B) ); | 383 | sum += (f32) ( logf(A) / logf(B) ); |
384 | count++; | 384 | count++; |
385 | } | 385 | } |
386 | } | 386 | } |
387 | if ( count && sum ) { | 387 | if ( count && sum ) { |
388 | gamma = 1.0f / (sum / count); | 388 | gamma = 1.0f / (sum / count); |
389 | } | 389 | } |
390 | 390 | ||
391 | } | 391 | } |
392 | 392 | ||
393 | //! Set the current Gamma Value for the Display | 393 | //! Set the current Gamma Value for the Display |
394 | bool CIrrDeviceStub::setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) | 394 | bool CIrrDeviceStub::setGammaRamp( f32 red, f32 green, f32 blue, f32 brightness, f32 contrast ) |
395 | { | 395 | { |
396 | return false; | 396 | return false; |
397 | } | 397 | } |
398 | 398 | ||
399 | //! Get the current Gamma Value for the Display | 399 | //! Get the current Gamma Value for the Display |
400 | bool CIrrDeviceStub::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ) | 400 | bool CIrrDeviceStub::getGammaRamp( f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast ) |
401 | { | 401 | { |
402 | return false; | 402 | return false; |
403 | } | 403 | } |
404 | 404 | ||
405 | //! Set the maximal elapsed time between 2 clicks to generate doubleclicks for the mouse. It also affects tripleclick behavior. | 405 | //! Set the maximal elapsed time between 2 clicks to generate doubleclicks for the mouse. It also affects tripleclick behavior. |
406 | void CIrrDeviceStub::setDoubleClickTime( u32 timeMs ) | 406 | void CIrrDeviceStub::setDoubleClickTime( u32 timeMs ) |
407 | { | 407 | { |
408 | MouseMultiClicks.DoubleClickTime = timeMs; | 408 | MouseMultiClicks.DoubleClickTime = timeMs; |
409 | } | 409 | } |
410 | 410 | ||
411 | //! Get the maximal elapsed time between 2 clicks to generate double- and tripleclicks for the mouse. | 411 | //! Get the maximal elapsed time between 2 clicks to generate double- and tripleclicks for the mouse. |
412 | u32 CIrrDeviceStub::getDoubleClickTime() const | 412 | u32 CIrrDeviceStub::getDoubleClickTime() const |
413 | { | 413 | { |
414 | return MouseMultiClicks.DoubleClickTime; | 414 | return MouseMultiClicks.DoubleClickTime; |
415 | } | 415 | } |
416 | 416 | ||
417 | //! Remove all messages pending in the system message loop | 417 | //! Remove all messages pending in the system message loop |
418 | void CIrrDeviceStub::clearSystemMessages() | 418 | void CIrrDeviceStub::clearSystemMessages() |
419 | { | 419 | { |
420 | } | 420 | } |
421 | 421 | ||
422 | 422 | ||
423 | 423 | ||
424 | } // end namespace irr | 424 | } // end namespace irr |
425 | 425 | ||