Changed: #1275 Compilation under Mac OS X

This commit is contained in:
kervala 2012-05-15 12:58:20 +02:00
parent ab0ae74358
commit 983b49fbb6
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 stencilMask(uint mask);
GfxMode _CurrentMode;
sint32 _WindowX;
sint32 _WindowY;
#ifdef NL_OS_MAC
NLMISC::CCocoaEventEmitter _EventEmitter;
#endif
private:
virtual class IVertexBufferHardGL *createVertexBufferHard(uint size, uint numVertices, CVertexBuffer::TPreferredMemory vbType, CVertexBuffer *vb);
friend class CTextureDrvInfosGL;
friend class CVertexProgamDrvInfosGL;
private:
// Version of the driver. Not the interface version!! Increment when implementation of the driver change.
static const uint32 ReleaseVersion;
// Windows
nlWindow _win;
sint32 _WindowX;
sint32 _WindowY;
bool _WindowVisible;
bool _DestroyWindow;
bool _Maximized;
GfxMode _CurrentMode;
uint _Interval;
bool _Resizable;
@ -790,11 +792,7 @@ private:
#elif defined(NL_OS_MAC)
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;
NSAutoreleasePool* _autoreleasePool;
uint16 _backBufferHeight;

View file

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

View file

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

View file

@ -18,21 +18,42 @@
namespace NL3D
{
#ifdef NL_STATIC
#ifdef USE_OPENGLES
namespace NLDRIVERGLES {
#else
namespace NLDRIVERGL {
#endif
#endif
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>
{
NSMutableAttributedString* _characterStorage;
NSRange _markedRange;
NL3D::CDriverGL* _driver;
CDriverGL* _driver;
}
-(id)initWithFrame:(NSRect)frame;
-(void)dealloc;
-(void)keyDown:(NSEvent*)event;
-(void)setDriver:(NL3D::CDriverGL*)driver;
-(void)setDriver:(CDriverGL*)driver;
-(void)resizeWithOldSuperviewSize:(NSSize)oldBoundsSize;
@end

View file

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

View file

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

View file

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