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