mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-11 17:59:02 +00:00
Changed: #1275 Compilation under Mac OS X
This commit is contained in:
parent
ab0ae74358
commit
983b49fbb6
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 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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -20,32 +20,29 @@
|
|||
#include "cocoa_application_delegate.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
|
||||
if(driver && driver->ExitFunc)
|
||||
{
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
@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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -19,17 +19,13 @@
|
|||
|
||||
#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;
|
||||
driver->_CurrentMode.Width = rect.size.width;
|
||||
}
|
||||
NSRect rect = [[view superview] frame];
|
||||
driver->_CurrentMode.Height = rect.size.height;
|
||||
driver->_CurrentMode.Width = rect.size.width;
|
||||
}
|
||||
|
||||
|
||||
@implementation CocoaOpenGLView
|
||||
|
||||
-(id)initWithFrame:(NSRect)frame
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -19,28 +19,25 @@
|
|||
|
||||
#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
|
||||
NSRect windowRect = [window frame];
|
||||
// get the rect (position, size) of the window
|
||||
NSRect windowRect = [window frame];
|
||||
|
||||
// set x in driver
|
||||
driver->_WindowX = windowRect.origin.x;
|
||||
// set x in driver
|
||||
driver->_WindowX = windowRect.origin.x;
|
||||
|
||||
// map y from cocoa to NeL coordinates before setting in driver
|
||||
driver->_WindowY =
|
||||
screenRect.size.height - windowRect.size.height - windowRect.origin.y;
|
||||
}
|
||||
// map y from cocoa to NeL coordinates before setting in driver
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue