Changed: #1275 Compilation under Mac OS X

This commit is contained in:
kervala 2012-05-15 12:58:20 +02:00
parent 9b2b51b6a5
commit c147b63082
7 changed files with 83 additions and 70 deletions

View file

@ -679,26 +679,28 @@ public:
virtual void stencilOp(TStencilOp fail, TStencilOp zfail, TStencilOp zpass); virtual void stencilOp(TStencilOp fail, TStencilOp zfail, TStencilOp zpass);
virtual void stencilMask(uint mask); virtual void stencilMask(uint mask);
GfxMode _CurrentMode;
sint32 _WindowX;
sint32 _WindowY;
#ifdef NL_OS_MAC
NLMISC::CCocoaEventEmitter _EventEmitter;
#endif
private: private:
virtual class IVertexBufferHardGL *createVertexBufferHard(uint size, uint numVertices, CVertexBuffer::TPreferredMemory vbType, CVertexBuffer *vb); virtual class IVertexBufferHardGL *createVertexBufferHard(uint size, uint numVertices, CVertexBuffer::TPreferredMemory vbType, CVertexBuffer *vb);
friend class CTextureDrvInfosGL; friend class CTextureDrvInfosGL;
friend class CVertexProgamDrvInfosGL; friend class CVertexProgamDrvInfosGL;
private: private:
// Version of the driver. Not the interface version!! Increment when implementation of the driver change. // Version of the driver. Not the interface version!! Increment when implementation of the driver change.
static const uint32 ReleaseVersion; static const uint32 ReleaseVersion;
// Windows // Windows
nlWindow _win; nlWindow _win;
sint32 _WindowX;
sint32 _WindowY;
bool _WindowVisible; bool _WindowVisible;
bool _DestroyWindow; bool _DestroyWindow;
bool _Maximized; bool _Maximized;
GfxMode _CurrentMode;
uint _Interval; uint _Interval;
bool _Resizable; bool _Resizable;
@ -790,11 +792,7 @@ private:
#elif defined(NL_OS_MAC) #elif defined(NL_OS_MAC)
friend bool GlWndProc(CDriverGL*, const void*); friend bool GlWndProc(CDriverGL*, const void*);
friend void windowDidMove(NSWindow*, CDriverGL*);
friend void viewDidResize(NSView*, CDriverGL*);
friend NSApplicationTerminateReply applicationShouldTerminate(CDriverGL*);
NLMISC::CCocoaEventEmitter _EventEmitter;
CocoaOpenGLView* _glView; CocoaOpenGLView* _glView;
NSAutoreleasePool* _autoreleasePool; NSAutoreleasePool* _autoreleasePool;
uint16 _backBufferHeight; uint16 _backBufferHeight;

View file

@ -16,21 +16,23 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
namespace NL3D #ifdef NL_STATIC
{ #ifdef USE_OPENGLES
class CDriverGL; using NL3D::NLDRIVERGLES::CDriverGL;
NSApplicationTerminateReply applicationShouldTerminate(CDriverGL*); #else
} using NL3D::NLDRIVERGL::CDriverGL;
#endif
#endif
@interface CocoaApplicationDelegate : NSObject @interface CocoaApplicationDelegate : NSObject
#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 #if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
<NSApplicationDelegate> <NSApplicationDelegate>
#endif #endif
{ {
NL3D::CDriverGL* _driver; CDriverGL* _driver;
} }
-(id)initWithDriver:(NL3D::CDriverGL*)driver; -(id)initWithDriver:(CDriverGL*)driver;
-(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; -(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
@end @end

View file

@ -20,9 +20,7 @@
#include "cocoa_application_delegate.h" #include "cocoa_application_delegate.h"
#include "cocoa_event_emitter.h" #include "cocoa_event_emitter.h"
namespace NL3D static NSApplicationTerminateReply applicationShouldTerminate(CDriverGL* driver)
{
NSApplicationTerminateReply applicationShouldTerminate(CDriverGL* driver)
{ {
// cancel if there is a driver and a custom exit handler set up // cancel if there is a driver and a custom exit handler set up
if(driver && driver->ExitFunc) if(driver && driver->ExitFunc)
@ -41,11 +39,10 @@ namespace NL3D
// just let the app terminate if no custom quit handling worked // just let the app terminate if no custom quit handling worked
return NSTerminateNow; return NSTerminateNow;
} }
}
@implementation CocoaApplicationDelegate @implementation CocoaApplicationDelegate
-(id)initWithDriver:(NL3D::CDriverGL*)driver -(id)initWithDriver:(CDriverGL*)driver
{ {
if((self = [super init])) if((self = [super init]))
{ {
@ -57,7 +54,7 @@ namespace NL3D
-(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender -(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender
{ {
return NL3D::applicationShouldTerminate(_driver); return applicationShouldTerminate(_driver);
} }
@end @end

View file

@ -18,21 +18,42 @@
namespace NL3D namespace NL3D
{ {
#ifdef NL_STATIC
#ifdef USE_OPENGLES
namespace NLDRIVERGLES {
#else
namespace NLDRIVERGL {
#endif
#endif
class CDriverGL; class CDriverGL;
void viewDidResize(NSView*, CDriverGL*);
#ifdef NL_STATIC
} // NLDRIVERGL/ES
#endif
} }
#ifdef NL_STATIC
#ifdef USE_OPENGLES
using NL3D::NLDRIVERGLES::CDriverGL;
#else
using NL3D::NLDRIVERGL::CDriverGL;
#endif
#endif
@interface CocoaOpenGLView : NSOpenGLView<NSTextInputClient> @interface CocoaOpenGLView : NSOpenGLView<NSTextInputClient>
{ {
NSMutableAttributedString* _characterStorage; NSMutableAttributedString* _characterStorage;
NSRange _markedRange; NSRange _markedRange;
NL3D::CDriverGL* _driver; CDriverGL* _driver;
} }
-(id)initWithFrame:(NSRect)frame; -(id)initWithFrame:(NSRect)frame;
-(void)dealloc; -(void)dealloc;
-(void)keyDown:(NSEvent*)event; -(void)keyDown:(NSEvent*)event;
-(void)setDriver:(NL3D::CDriverGL*)driver; -(void)setDriver:(CDriverGL*)driver;
-(void)resizeWithOldSuperviewSize:(NSSize)oldBoundsSize; -(void)resizeWithOldSuperviewSize:(NSSize)oldBoundsSize;
@end @end

View file

@ -19,16 +19,12 @@
#import "cocoa_opengl_view.h" #import "cocoa_opengl_view.h"
namespace NL3D static void viewDidResize(NSView* view, CDriverGL* driver)
{
void viewDidResize(NSView* view, CDriverGL* driver)
{ {
NSRect rect = [[view superview] frame]; NSRect rect = [[view superview] frame];
driver->_CurrentMode.Height = rect.size.height; driver->_CurrentMode.Height = rect.size.height;
driver->_CurrentMode.Width = rect.size.width; driver->_CurrentMode.Width = rect.size.width;
} }
}
@implementation CocoaOpenGLView @implementation CocoaOpenGLView
@ -56,7 +52,7 @@ namespace NL3D
#endif #endif
} }
-(void)setDriver:(NL3D::CDriverGL*)driver -(void)setDriver:(CDriverGL*)driver
{ {
_driver = driver; _driver = driver;
} }
@ -68,7 +64,7 @@ namespace NL3D
if(!_driver) if(!_driver)
return; return;
NL3D::viewDidResize(self, _driver); viewDidResize(self, _driver);
} }
/******************************************************************************/ /******************************************************************************/

View file

@ -17,21 +17,23 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#include "AvailabilityMacros.h" #include "AvailabilityMacros.h"
namespace NL3D #ifdef NL_STATIC
{ #ifdef USE_OPENGLES
class CDriverGL; using NL3D::NLDRIVERGLES::CDriverGL;
void windowDidMove(NSWindow*, NL3D::CDriverGL*); #else
} using NL3D::NLDRIVERGL::CDriverGL;
#endif
#endif
@interface CocoaWindowDelegate : NSObject @interface CocoaWindowDelegate : NSObject
#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 #if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
<NSWindowDelegate> <NSWindowDelegate>
#endif #endif
{ {
NL3D::CDriverGL* _driver; CDriverGL* _driver;
} }
- (id)initWithDriver:(NL3D::CDriverGL*)driver; - (id)initWithDriver:(CDriverGL*)driver;
- (void)windowDidMove:(NSNotification*)notification; - (void)windowDidMove:(NSNotification*)notification;
@end @end

View file

@ -19,9 +19,7 @@
#import "cocoa_window_delegate.h" #import "cocoa_window_delegate.h"
namespace NL3D static void windowDidMove(NSWindow* window, CDriverGL* driver)
{
void windowDidMove(NSWindow* window, NL3D::CDriverGL* driver)
{ {
// get the rect (position, size) of the screen with menu bar // get the rect (position, size) of the screen with menu bar
NSRect screenRect = [[[NSScreen screens] objectAtIndex:0] frame]; NSRect screenRect = [[[NSScreen screens] objectAtIndex:0] frame];
@ -36,11 +34,10 @@ namespace NL3D
driver->_WindowY = driver->_WindowY =
screenRect.size.height - windowRect.size.height - windowRect.origin.y; screenRect.size.height - windowRect.size.height - windowRect.origin.y;
} }
}
@implementation CocoaWindowDelegate @implementation CocoaWindowDelegate
-(id)initWithDriver:(NL3D::CDriverGL*)driver -(id)initWithDriver:(CDriverGL*)driver
{ {
if((self = [super init])) if((self = [super init]))
{ {
@ -56,7 +53,7 @@ namespace NL3D
if(!_driver) if(!_driver)
return; return;
NL3D::windowDidMove([notification object], _driver); windowDidMove([notification object], _driver);
} }
@end @end