mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-27 01:06:19 +00:00
Changed: #1275 Compilation under Mac OS X
This commit is contained in:
parent
9b2b51b6a5
commit
c147b63082
7 changed files with 83 additions and 70 deletions
|
@ -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;
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -20,32 +20,29 @@
|
||||||
#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
|
||||||
|
if(driver && driver->ExitFunc)
|
||||||
{
|
{
|
||||||
// cancel if there is a driver and a custom exit handler set up
|
driver->ExitFunc();
|
||||||
if(driver && driver->ExitFunc)
|
return NSTerminateCancel;
|
||||||
{
|
|
||||||
driver->ExitFunc();
|
|
||||||
return NSTerminateCancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
NLMISC::CCocoaEventEmitter* eventEmitter =
|
|
||||||
NLMISC::safe_cast<NLMISC::CCocoaEventEmitter*>(&(driver->_EventEmitter));
|
|
||||||
|
|
||||||
// cancel if there is a driver and cocoa event emitter handles the quit
|
|
||||||
if(driver && eventEmitter && eventEmitter->handleQuitRequest())
|
|
||||||
return NSTerminateCancel;
|
|
||||||
|
|
||||||
// just let the app terminate if no custom quit handling worked
|
|
||||||
return NSTerminateNow;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NLMISC::CCocoaEventEmitter* eventEmitter =
|
||||||
|
NLMISC::safe_cast<NLMISC::CCocoaEventEmitter*>(&(driver->_EventEmitter));
|
||||||
|
|
||||||
|
// cancel if there is a driver and cocoa event emitter handles the quit
|
||||||
|
if(driver && eventEmitter && eventEmitter->handleQuitRequest())
|
||||||
|
return NSTerminateCancel;
|
||||||
|
|
||||||
|
// just let the app terminate if no custom quit handling worked
|
||||||
|
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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -19,17 +19,13 @@
|
||||||
|
|
||||||
#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];
|
||||||
{
|
driver->_CurrentMode.Height = rect.size.height;
|
||||||
NSRect rect = [[view superview] frame];
|
driver->_CurrentMode.Width = rect.size.width;
|
||||||
driver->_CurrentMode.Height = rect.size.height;
|
|
||||||
driver->_CurrentMode.Width = rect.size.width;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@implementation CocoaOpenGLView
|
@implementation CocoaOpenGLView
|
||||||
|
|
||||||
-(id)initWithFrame:(NSRect)frame
|
-(id)initWithFrame:(NSRect)frame
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -19,28 +19,25 @@
|
||||||
|
|
||||||
#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
|
||||||
{
|
NSRect screenRect = [[[NSScreen screens] objectAtIndex:0] frame];
|
||||||
// get the rect (position, size) of the screen with menu bar
|
|
||||||
NSRect screenRect = [[[NSScreen screens] objectAtIndex:0] frame];
|
|
||||||
|
|
||||||
// get the rect (position, size) of the window
|
// get the rect (position, size) of the window
|
||||||
NSRect windowRect = [window frame];
|
NSRect windowRect = [window frame];
|
||||||
|
|
||||||
// set x in driver
|
// set x in driver
|
||||||
driver->_WindowX = windowRect.origin.x;
|
driver->_WindowX = windowRect.origin.x;
|
||||||
|
|
||||||
// map y from cocoa to NeL coordinates before setting in driver
|
// map y from cocoa to NeL coordinates before setting in driver
|
||||||
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
|
||||||
|
|
Loading…
Reference in a new issue