aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h
diff options
context:
space:
mode:
authorDavid Walter Seikel2013-01-13 18:54:10 +1000
committerDavid Walter Seikel2013-01-13 18:54:10 +1000
commit959831f4ef5a3e797f576c3de08cd65032c997ad (patch)
treee7351908be5995f0b325b2ebeaa02d5a34b82583 /libraries/irrlicht-1.8/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h
parentAdd info about changes to Irrlicht. (diff)
downloadSledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.zip
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.gz
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.bz2
SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.xz
Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard.
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h502
1 files changed, 251 insertions, 251 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h b/libraries/irrlicht-1.8/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h
index 174c68f..5b8ab9a 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h
+++ b/libraries/irrlicht-1.8/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h
@@ -1,251 +1,251 @@
1// Copyright (C) 2005-2006 Etienne Petitjean 1// Copyright (C) 2005-2006 Etienne Petitjean
2// Copyright (C) 2007-2012 Christian Stehno 2// Copyright (C) 2007-2012 Christian Stehno
3// This file is part of the "Irrlicht Engine". 3// This file is part of the "Irrlicht Engine".
4// For conditions of distribution and use, see copyright notice in Irrlicht.h 4// For conditions of distribution and use, see copyright notice in Irrlicht.h
5 5
6#ifndef __C_IRR_DEVICE_MACOSX_H_INCLUDED__ 6#ifndef __C_IRR_DEVICE_MACOSX_H_INCLUDED__
7#define __C_IRR_DEVICE_MACOSX_H_INCLUDED__ 7#define __C_IRR_DEVICE_MACOSX_H_INCLUDED__
8 8
9#include "IrrCompileConfig.h" 9#include "IrrCompileConfig.h"
10 10
11#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ 11#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_
12 12
13#include "CIrrDeviceStub.h" 13#include "CIrrDeviceStub.h"
14#include "IrrlichtDevice.h" 14#include "IrrlichtDevice.h"
15#include "IImagePresenter.h" 15#include "IImagePresenter.h"
16#include "IGUIEnvironment.h" 16#include "IGUIEnvironment.h"
17#include "ICursorControl.h" 17#include "ICursorControl.h"
18 18
19#include <OpenGL/OpenGL.h> 19#include <OpenGL/OpenGL.h>
20#include <map> 20#include <map>
21 21
22class NSWindow; 22class NSWindow;
23class NSOpenGLContext; 23class NSOpenGLContext;
24class NSBitmapImageRep; 24class NSBitmapImageRep;
25 25
26namespace irr 26namespace irr
27{ 27{
28 class CIrrDeviceMacOSX : public CIrrDeviceStub, video::IImagePresenter 28 class CIrrDeviceMacOSX : public CIrrDeviceStub, video::IImagePresenter
29 { 29 {
30 public: 30 public:
31 31
32 //! constructor 32 //! constructor
33 CIrrDeviceMacOSX(const SIrrlichtCreationParameters& params); 33 CIrrDeviceMacOSX(const SIrrlichtCreationParameters& params);
34 34
35 //! destructor 35 //! destructor
36 virtual ~CIrrDeviceMacOSX(); 36 virtual ~CIrrDeviceMacOSX();
37 37
38 //! runs the device. Returns false if device wants to be deleted 38 //! runs the device. Returns false if device wants to be deleted
39 virtual bool run(); 39 virtual bool run();
40 40
41 //! Cause the device to temporarily pause execution and let other processes to run 41 //! Cause the device to temporarily pause execution and let other processes to run
42 // This should bring down processor usage without major performance loss for Irrlicht 42 // This should bring down processor usage without major performance loss for Irrlicht
43 virtual void yield(); 43 virtual void yield();
44 44
45 //! Pause execution and let other processes to run for a specified amount of time. 45 //! Pause execution and let other processes to run for a specified amount of time.
46 virtual void sleep(u32 timeMs, bool pauseTimer); 46 virtual void sleep(u32 timeMs, bool pauseTimer);
47 47
48 //! sets the caption of the window 48 //! sets the caption of the window
49 virtual void setWindowCaption(const wchar_t* text); 49 virtual void setWindowCaption(const wchar_t* text);
50 50
51 //! returns if window is active. if not, nothing need to be drawn 51 //! returns if window is active. if not, nothing need to be drawn
52 virtual bool isWindowActive() const; 52 virtual bool isWindowActive() const;
53 53
54 //! Checks if the Irrlicht window has focus 54 //! Checks if the Irrlicht window has focus
55 virtual bool isWindowFocused() const; 55 virtual bool isWindowFocused() const;
56 56
57 //! Checks if the Irrlicht window is minimized 57 //! Checks if the Irrlicht window is minimized
58 virtual bool isWindowMinimized() const; 58 virtual bool isWindowMinimized() const;
59 59
60 //! presents a surface in the client area 60 //! presents a surface in the client area
61 virtual bool present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0 ); 61 virtual bool present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0 );
62 62
63 //! notifies the device that it should close itself 63 //! notifies the device that it should close itself
64 virtual void closeDevice(); 64 virtual void closeDevice();
65 65
66 //! Sets if the window should be resizable in windowed mode. 66 //! Sets if the window should be resizable in windowed mode.
67 virtual void setResizable(bool resize); 67 virtual void setResizable(bool resize);
68 68
69 //! Returns true if the window is resizable, false if not 69 //! Returns true if the window is resizable, false if not
70 virtual bool isResizable() const; 70 virtual bool isResizable() const;
71 71
72 //! Minimizes the window if possible 72 //! Minimizes the window if possible
73 virtual void minimizeWindow(); 73 virtual void minimizeWindow();
74 74
75 //! Maximizes the window if possible. 75 //! Maximizes the window if possible.
76 virtual void maximizeWindow(); 76 virtual void maximizeWindow();
77 77
78 //! Restore the window to normal size if possible. 78 //! Restore the window to normal size if possible.
79 virtual void restoreWindow(); 79 virtual void restoreWindow();
80 80
81 //! Activate any joysticks, and generate events for them. 81 //! Activate any joysticks, and generate events for them.
82 virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo); 82 virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo);
83 83
84 //! \return Returns a pointer to a list with all video modes 84 //! \return Returns a pointer to a list with all video modes
85 //! supported by the gfx adapter. 85 //! supported by the gfx adapter.
86 virtual video::IVideoModeList* getVideoModeList(); 86 virtual video::IVideoModeList* getVideoModeList();
87 87
88 //! Get the device type 88 //! Get the device type
89 virtual E_DEVICE_TYPE getType() const 89 virtual E_DEVICE_TYPE getType() const
90 { 90 {
91 return EIDT_OSX; 91 return EIDT_OSX;
92 } 92 }
93 93
94 void flush(); 94 void flush();
95 void setMouseLocation(int x, int y); 95 void setMouseLocation(int x, int y);
96 void setResize(int width, int height); 96 void setResize(int width, int height);
97 void setCursorVisible(bool visible); 97 void setCursorVisible(bool visible);
98 98
99 private: 99 private:
100 100
101 //! create the driver 101 //! create the driver
102 void createDriver(); 102 void createDriver();
103 103
104 //! Implementation of the macos x cursor control 104 //! Implementation of the macos x cursor control
105 class CCursorControl : public gui::ICursorControl 105 class CCursorControl : public gui::ICursorControl
106 { 106 {
107 public: 107 public:
108 108
109 CCursorControl(const core::dimension2d<u32>& wsize, CIrrDeviceMacOSX *device) 109 CCursorControl(const core::dimension2d<u32>& wsize, CIrrDeviceMacOSX *device)
110 : WindowSize(wsize), IsVisible(true), InvWindowSize(0.0f, 0.0f), Device(device), UseReferenceRect(false) 110 : WindowSize(wsize), IsVisible(true), InvWindowSize(0.0f, 0.0f), Device(device), UseReferenceRect(false)
111 { 111 {
112 CursorPos.X = CursorPos.Y = 0; 112 CursorPos.X = CursorPos.Y = 0;
113 if (WindowSize.Width!=0) 113 if (WindowSize.Width!=0)
114 InvWindowSize.Width = 1.0f / WindowSize.Width; 114 InvWindowSize.Width = 1.0f / WindowSize.Width;
115 if (WindowSize.Height!=0) 115 if (WindowSize.Height!=0)
116 InvWindowSize.Height = 1.0f / WindowSize.Height; 116 InvWindowSize.Height = 1.0f / WindowSize.Height;
117 } 117 }
118 118
119 //! Changes the visible state of the mouse cursor. 119 //! Changes the visible state of the mouse cursor.
120 virtual void setVisible(bool visible) 120 virtual void setVisible(bool visible)
121 { 121 {
122 IsVisible = visible; 122 IsVisible = visible;
123 Device->setCursorVisible(visible); 123 Device->setCursorVisible(visible);
124 } 124 }
125 125
126 //! Returns if the cursor is currently visible. 126 //! Returns if the cursor is currently visible.
127 virtual bool isVisible() const 127 virtual bool isVisible() const
128 { 128 {
129 return IsVisible; 129 return IsVisible;
130 } 130 }
131 131
132 //! Sets the new position of the cursor. 132 //! Sets the new position of the cursor.
133 virtual void setPosition(const core::position2d<f32> &pos) 133 virtual void setPosition(const core::position2d<f32> &pos)
134 { 134 {
135 setPosition(pos.X, pos.Y); 135 setPosition(pos.X, pos.Y);
136 } 136 }
137 137
138 //! Sets the new position of the cursor. 138 //! Sets the new position of the cursor.
139 virtual void setPosition(f32 x, f32 y) 139 virtual void setPosition(f32 x, f32 y)
140 { 140 {
141 setPosition((s32)(x*WindowSize.Width), (s32)(y*WindowSize.Height)); 141 setPosition((s32)(x*WindowSize.Width), (s32)(y*WindowSize.Height));
142 } 142 }
143 143
144 //! Sets the new position of the cursor. 144 //! Sets the new position of the cursor.
145 virtual void setPosition(const core::position2d<s32> &pos) 145 virtual void setPosition(const core::position2d<s32> &pos)
146 { 146 {
147 if (CursorPos.X != pos.X || CursorPos.Y != pos.Y) 147 if (CursorPos.X != pos.X || CursorPos.Y != pos.Y)
148 setPosition(pos.X, pos.Y); 148 setPosition(pos.X, pos.Y);
149 } 149 }
150 150
151 //! Sets the new position of the cursor. 151 //! Sets the new position of the cursor.
152 virtual void setPosition(s32 x, s32 y) 152 virtual void setPosition(s32 x, s32 y)
153 { 153 {
154 if (UseReferenceRect) 154 if (UseReferenceRect)
155 { 155 {
156 Device->setMouseLocation(ReferenceRect.UpperLeftCorner.X + x, ReferenceRect.UpperLeftCorner.Y + y); 156 Device->setMouseLocation(ReferenceRect.UpperLeftCorner.X + x, ReferenceRect.UpperLeftCorner.Y + y);
157 } 157 }
158 else 158 else
159 { 159 {
160 Device->setMouseLocation(x,y); 160 Device->setMouseLocation(x,y);
161 } 161 }
162 } 162 }
163 163
164 //! Returns the current position of the mouse cursor. 164 //! Returns the current position of the mouse cursor.
165 virtual const core::position2d<s32>& getPosition() 165 virtual const core::position2d<s32>& getPosition()
166 { 166 {
167 return CursorPos; 167 return CursorPos;
168 } 168 }
169 169
170 //! Returns the current position of the mouse cursor. 170 //! Returns the current position of the mouse cursor.
171 virtual core::position2d<f32> getRelativePosition() 171 virtual core::position2d<f32> getRelativePosition()
172 { 172 {
173 if (!UseReferenceRect) 173 if (!UseReferenceRect)
174 { 174 {
175 return core::position2d<f32>(CursorPos.X * InvWindowSize.Width, 175 return core::position2d<f32>(CursorPos.X * InvWindowSize.Width,
176 CursorPos.Y * InvWindowSize.Height); 176 CursorPos.Y * InvWindowSize.Height);
177 } 177 }
178 178
179 return core::position2d<f32>(CursorPos.X / (f32)ReferenceRect.getWidth(), 179 return core::position2d<f32>(CursorPos.X / (f32)ReferenceRect.getWidth(),
180 CursorPos.Y / (f32)ReferenceRect.getHeight()); 180 CursorPos.Y / (f32)ReferenceRect.getHeight());
181 } 181 }
182 182
183 //! Sets an absolute reference rect for calculating the cursor position. 183 //! Sets an absolute reference rect for calculating the cursor position.
184 virtual void setReferenceRect(core::rect<s32>* rect=0) 184 virtual void setReferenceRect(core::rect<s32>* rect=0)
185 { 185 {
186 if (rect) 186 if (rect)
187 { 187 {
188 ReferenceRect = *rect; 188 ReferenceRect = *rect;
189 UseReferenceRect = true; 189 UseReferenceRect = true;
190 190
191 // prevent division through zero and uneven sizes 191 // prevent division through zero and uneven sizes
192 192
193 if (!ReferenceRect.getHeight() || ReferenceRect.getHeight()%2) 193 if (!ReferenceRect.getHeight() || ReferenceRect.getHeight()%2)
194 ReferenceRect.LowerRightCorner.Y += 1; 194 ReferenceRect.LowerRightCorner.Y += 1;
195 195
196 if (!ReferenceRect.getWidth() || ReferenceRect.getWidth()%2) 196 if (!ReferenceRect.getWidth() || ReferenceRect.getWidth()%2)
197 ReferenceRect.LowerRightCorner.X += 1; 197 ReferenceRect.LowerRightCorner.X += 1;
198 } 198 }
199 else 199 else
200 UseReferenceRect = false; 200 UseReferenceRect = false;
201 } 201 }
202 202
203 //! Updates the internal cursor position 203 //! Updates the internal cursor position
204 void updateInternalCursorPosition(int x,int y) 204 void updateInternalCursorPosition(int x,int y)
205 { 205 {
206 CursorPos.X = x; 206 CursorPos.X = x;
207 CursorPos.Y = y; 207 CursorPos.Y = y;
208 } 208 }
209 209
210 private: 210 private:
211 211
212 core::position2d<s32> CursorPos; 212 core::position2d<s32> CursorPos;
213 core::dimension2d<s32> WindowSize; 213 core::dimension2d<s32> WindowSize;
214 core::dimension2d<float> InvWindowSize; 214 core::dimension2d<float> InvWindowSize;
215 core::rect<s32> ReferenceRect; 215 core::rect<s32> ReferenceRect;
216 CIrrDeviceMacOSX *Device; 216 CIrrDeviceMacOSX *Device;
217 bool IsVisible; 217 bool IsVisible;
218 bool UseReferenceRect; 218 bool UseReferenceRect;
219 }; 219 };
220 220
221 bool createWindow(); 221 bool createWindow();
222 void initKeycodes(); 222 void initKeycodes();
223 void storeMouseLocation(); 223 void storeMouseLocation();
224 void postMouseEvent(void *event, irr::SEvent &ievent); 224 void postMouseEvent(void *event, irr::SEvent &ievent);
225 void postKeyEvent(void *event, irr::SEvent &ievent, bool pressed); 225 void postKeyEvent(void *event, irr::SEvent &ievent, bool pressed);
226 void pollJoysticks(); 226 void pollJoysticks();
227 227
228 NSWindow *Window; 228 NSWindow *Window;
229 CGLContextObj CGLContext; 229 CGLContextObj CGLContext;
230 NSOpenGLContext *OGLContext; 230 NSOpenGLContext *OGLContext;
231 NSBitmapImageRep *SoftwareDriverTarget; 231 NSBitmapImageRep *SoftwareDriverTarget;
232 std::map<int,int> KeyCodes; 232 std::map<int,int> KeyCodes;
233 int DeviceWidth; 233 int DeviceWidth;
234 int DeviceHeight; 234 int DeviceHeight;
235 int ScreenWidth; 235 int ScreenWidth;
236 int ScreenHeight; 236 int ScreenHeight;
237 u32 MouseButtonStates; 237 u32 MouseButtonStates;
238 u32 SoftwareRendererType; 238 u32 SoftwareRendererType;
239 bool IsFullscreen; 239 bool IsFullscreen;
240 bool IsActive; 240 bool IsActive;
241 bool IsShiftDown; 241 bool IsShiftDown;
242 bool IsControlDown; 242 bool IsControlDown;
243 bool IsResizable; 243 bool IsResizable;
244 }; 244 };
245 245
246 246
247} // end namespace irr 247} // end namespace irr
248 248
249#endif // _IRR_COMPILE_WITH_OSX_DEVICE_ 249#endif // _IRR_COMPILE_WITH_OSX_DEVICE_
250#endif // __C_IRR_DEVICE_MACOSX_H_INCLUDED__ 250#endif // __C_IRR_DEVICE_MACOSX_H_INCLUDED__
251 251