Commit 8a0a5544 authored by bitplane's avatar bitplane

adapted OSX device code style to Irrlicht's rather than Cocoa's. Initial...

adapted OSX device code style to Irrlicht's rather than Cocoa's. Initial attempt at software driver support, isn't refreshing each frame yet

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2227 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 96ae0085
......@@ -122,13 +122,9 @@ int main()
dimensions, etc.
*/
IrrlichtDevice *device =
#ifdef _IRR_OSX_PLATFORM_
createDevice( video::EDT_OPENGL, dimension2d<u32>(640, 480), 16,
false, false, false, 0);
#else
createDevice( video::EDT_SOFTWARE, dimension2d<u32>(640, 480), 16,
false, false, false, 0);
#endif
if (!device)
return 1;
......
......@@ -48,6 +48,14 @@
_quit = TRUE;
}
- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize
{
if (_device->isResizeAble())
return proposedFrameSize;
else
return [window frame].size;
}
- (void)windowDidResize:(NSNotification *)aNotification
{
NSWindow *window;
......
......@@ -18,6 +18,10 @@
#include <OpenGL/OpenGL.h>
#include <map>
class NSWindow;
class NSOpenGLContext;
class NSBitmapImageRep;
namespace irr
{
class CIrrDeviceMacOSX : public CIrrDeviceStub, video::IImagePresenter
......@@ -58,9 +62,12 @@ namespace irr
//! notifies the device that it should close itself
virtual void closeDevice();
//! Sets if the window should be resizeable in windowed mode.
//! Sets if the window should be resizable in windowed mode.
virtual void setResizeAble(bool resize);
//! Returns true if the window is resizable, false if not
virtual bool isResizeAble() const;
//! Activate any joysticks, and generate events for them.
virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo);
......@@ -83,18 +90,21 @@ namespace irr
{
public:
CCursorControl(const core::dimension2d<u32>& wsize, CIrrDeviceMacOSX *device) : WindowSize(wsize), IsVisible(true), InvWindowSize(0.0f, 0.0f), _device(device), UseReferenceRect(false)
CCursorControl(const core::dimension2d<u32>& wsize, CIrrDeviceMacOSX *device)
: WindowSize(wsize), IsVisible(true), InvWindowSize(0.0f, 0.0f), Device(device), UseReferenceRect(false)
{
CursorPos.X = CursorPos.Y = 0;
if (WindowSize.Width!=0) InvWindowSize.Width = 1.0f / WindowSize.Width;
if (WindowSize.Height!=0) InvWindowSize.Height = 1.0f / WindowSize.Height;
if (WindowSize.Width!=0)
InvWindowSize.Width = 1.0f / WindowSize.Width;
if (WindowSize.Height!=0)
InvWindowSize.Height = 1.0f / WindowSize.Height;
}
//! Changes the visible state of the mouse cursor.
virtual void setVisible(bool visible)
{
IsVisible = visible;
_device->setCursorVisible(visible);
Device->setCursorVisible(visible);
}
//! Returns if the cursor is currently visible.
......@@ -127,11 +137,11 @@ namespace irr
{
if (UseReferenceRect)
{
_device->setMouseLocation(ReferenceRect.UpperLeftCorner.X + x, ReferenceRect.UpperLeftCorner.Y + y);
Device->setMouseLocation(ReferenceRect.UpperLeftCorner.X + x, ReferenceRect.UpperLeftCorner.Y + y);
}
else
{
_device->setMouseLocation(x,y);
Device->setMouseLocation(x,y);
}
}
......@@ -187,7 +197,7 @@ namespace irr
core::dimension2d<s32> WindowSize;
core::dimension2d<float> InvWindowSize;
core::rect<s32> ReferenceRect;
CIrrDeviceMacOSX *_device;
CIrrDeviceMacOSX *Device;
bool IsVisible;
bool UseReferenceRect;
};
......@@ -195,23 +205,25 @@ namespace irr
bool createWindow();
void initKeycodes();
void storeMouseLocation();
void postMouseEvent(void *event,irr::SEvent &ievent);
void postKeyEvent(void *event,irr::SEvent &ievent,bool pressed);
void *_window;
CGLContextObj _cglcontext;
void *_oglcontext;
int _width,
_height;
std::map<int,int> _keycodes;
int _screenWidth,
_screenHeight;
bool _active;
bool IsShiftDown,
IsControlDown;
u32 MouseButtonStates;
void postMouseEvent(void *event, irr::SEvent &ievent);
void postKeyEvent(void *event, irr::SEvent &ievent, bool pressed);
void pollJoysticks();
NSWindow *Window;
CGLContextObj CGLContext;
NSOpenGLContext *OGLContext;
int DeviceWidth,
DeviceHeight;
std::map<int,int> KeyCodes;
int ScreenWidth,
ScreenHeight;
bool IsActive;
NSBitmapImageRep *SoftwareDriverTarget;
bool IsSoftwareRenderer,
IsShiftDown,
IsControlDown,
IsResizable;
u32 MouseButtonStates;
};
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment