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() ...@@ -122,13 +122,9 @@ int main()
dimensions, etc. dimensions, etc.
*/ */
IrrlichtDevice *device = 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, createDevice( video::EDT_SOFTWARE, dimension2d<u32>(640, 480), 16,
false, false, false, 0); false, false, false, 0);
#endif
if (!device) if (!device)
return 1; return 1;
......
// Copyright (C) 2005-2009 Etienne Petitjean // Copyright (C) 2005-2009 Etienne Petitjean
// This file is part of the "Irrlicht Engine". // This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h // For conditions of distribution and use, see copyright notice in Irrlicht.h
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import "CIrrDeviceMacOSX.h" #import "CIrrDeviceMacOSX.h"
@interface AppDelegate : NSObject @interface AppDelegate : NSObject
{ {
BOOL _quit; BOOL _quit;
irr::CIrrDeviceMacOSX *_device; irr::CIrrDeviceMacOSX *_device;
} }
- (id)initWithDevice:(irr::CIrrDeviceMacOSX *)device; - (id)initWithDevice:(irr::CIrrDeviceMacOSX *)device;
- (BOOL)isQuit; - (BOOL)isQuit;
@end @end
// Copyright (C) 2005-2009 Etienne Petitjean // Copyright (C) 2005-2009 Etienne Petitjean
// This file is part of the "Irrlicht Engine". // This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in Irrlicht.h // For conditions of distribution and use, see copyright notice in Irrlicht.h
#import "AppDelegate.h" #import "AppDelegate.h"
@implementation AppDelegate @implementation AppDelegate
- (id)initWithDevice:(irr::CIrrDeviceMacOSX *)device - (id)initWithDevice:(irr::CIrrDeviceMacOSX *)device
{ {
self = [super init]; self = [super init];
if (self) _device = device; if (self) _device = device;
return (self); return (self);
} }
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{ {
_quit = FALSE; _quit = FALSE;
} }
- (void)orderFrontStandardAboutPanel:(id)sender - (void)orderFrontStandardAboutPanel:(id)sender
{ {
[NSApp orderFrontStandardAboutPanel:sender]; [NSApp orderFrontStandardAboutPanel:sender];
} }
- (void)unhideAllApplications:(id)sender - (void)unhideAllApplications:(id)sender
{ {
[NSApp unhideAllApplications:sender]; [NSApp unhideAllApplications:sender];
} }
- (void)hide:(id)sender - (void)hide:(id)sender
{ {
[NSApp hide:sender]; [NSApp hide:sender];
} }
- (void)hideOtherApplications:(id)sender - (void)hideOtherApplications:(id)sender
{ {
[NSApp hideOtherApplications:sender]; [NSApp hideOtherApplications:sender];
} }
- (void)terminate:(id)sender - (void)terminate:(id)sender
{ {
_quit = TRUE; _quit = TRUE;
} }
- (void)windowWillClose:(id)sender - (void)windowWillClose:(id)sender
{ {
_quit = TRUE; _quit = TRUE;
} }
- (void)windowDidResize:(NSNotification *)aNotification - (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize
{ {
NSWindow *window; if (_device->isResizeAble())
NSRect frame; return proposedFrameSize;
else
window = [aNotification object]; return [window frame].size;
frame = [window frame]; }
_device->setResize((int)frame.size.width,(int)frame.size.height);
} - (void)windowDidResize:(NSNotification *)aNotification
{
- (BOOL)isQuit NSWindow *window;
{ NSRect frame;
return (_quit);
} window = [aNotification object];
frame = [window frame];
@end _device->setResize((int)frame.size.width,(int)frame.size.height);
}
- (BOOL)isQuit
{
return (_quit);
}
@end
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
#include <OpenGL/OpenGL.h> #include <OpenGL/OpenGL.h>
#include <map> #include <map>
class NSWindow;
class NSOpenGLContext;
class NSBitmapImageRep;
namespace irr namespace irr
{ {
class CIrrDeviceMacOSX : public CIrrDeviceStub, video::IImagePresenter class CIrrDeviceMacOSX : public CIrrDeviceStub, video::IImagePresenter
...@@ -58,8 +62,11 @@ namespace irr ...@@ -58,8 +62,11 @@ namespace irr
//! notifies the device that it should close itself //! notifies the device that it should close itself
virtual void closeDevice(); 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); 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. //! Activate any joysticks, and generate events for them.
virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo); virtual bool activateJoysticks(core::array<SJoystickInfo> & joystickInfo);
...@@ -83,18 +90,21 @@ namespace irr ...@@ -83,18 +90,21 @@ namespace irr
{ {
public: 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; CursorPos.X = CursorPos.Y = 0;
if (WindowSize.Width!=0) InvWindowSize.Width = 1.0f / WindowSize.Width; if (WindowSize.Width!=0)
if (WindowSize.Height!=0) InvWindowSize.Height = 1.0f / WindowSize.Height; InvWindowSize.Width = 1.0f / WindowSize.Width;
if (WindowSize.Height!=0)
InvWindowSize.Height = 1.0f / WindowSize.Height;
} }
//! Changes the visible state of the mouse cursor. //! Changes the visible state of the mouse cursor.
virtual void setVisible(bool visible) virtual void setVisible(bool visible)
{ {
IsVisible = visible; IsVisible = visible;
_device->setCursorVisible(visible); Device->setCursorVisible(visible);
} }
//! Returns if the cursor is currently visible. //! Returns if the cursor is currently visible.
...@@ -127,11 +137,11 @@ namespace irr ...@@ -127,11 +137,11 @@ namespace irr
{ {
if (UseReferenceRect) if (UseReferenceRect)
{ {
_device->setMouseLocation(ReferenceRect.UpperLeftCorner.X + x, ReferenceRect.UpperLeftCorner.Y + y); Device->setMouseLocation(ReferenceRect.UpperLeftCorner.X + x, ReferenceRect.UpperLeftCorner.Y + y);
} }
else else
{ {
_device->setMouseLocation(x,y); Device->setMouseLocation(x,y);
} }
} }
...@@ -187,7 +197,7 @@ namespace irr ...@@ -187,7 +197,7 @@ namespace irr
core::dimension2d<s32> WindowSize; core::dimension2d<s32> WindowSize;
core::dimension2d<float> InvWindowSize; core::dimension2d<float> InvWindowSize;
core::rect<s32> ReferenceRect; core::rect<s32> ReferenceRect;
CIrrDeviceMacOSX *_device; CIrrDeviceMacOSX *Device;
bool IsVisible; bool IsVisible;
bool UseReferenceRect; bool UseReferenceRect;
}; };
...@@ -195,23 +205,25 @@ namespace irr ...@@ -195,23 +205,25 @@ namespace irr
bool createWindow(); bool createWindow();
void initKeycodes(); void initKeycodes();
void storeMouseLocation(); void storeMouseLocation();
void postMouseEvent(void *event,irr::SEvent &ievent); void postMouseEvent(void *event, irr::SEvent &ievent);
void postKeyEvent(void *event,irr::SEvent &ievent,bool pressed); 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 pollJoysticks(); 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