mirror of https://github.com/AxioDL/boo.git
OS X fixes
This commit is contained in:
parent
181a038901
commit
0be417f0b0
|
@ -53,7 +53,9 @@ elseif(APPLE)
|
||||||
find_library(APPKIT_LIBRARY AppKit)
|
find_library(APPKIT_LIBRARY AppKit)
|
||||||
find_library(IOKIT_LIBRARY IOKit)
|
find_library(IOKIT_LIBRARY IOKit)
|
||||||
find_library(OPENGL_LIBRARY OpenGL)
|
find_library(OPENGL_LIBRARY OpenGL)
|
||||||
|
if (CMAKE_OSX_DEPLOYMENT_TARGET VERSION_GREATER 10.10)
|
||||||
find_library(METAL_LIBRARY Metal)
|
find_library(METAL_LIBRARY Metal)
|
||||||
|
endif()
|
||||||
find_library(QUARTZCORE_LIBRARY QuartzCore)
|
find_library(QUARTZCORE_LIBRARY QuartzCore)
|
||||||
find_library(COREVIDEO_LIBRARY CoreVideo)
|
find_library(COREVIDEO_LIBRARY CoreVideo)
|
||||||
list(APPEND _BOO_SYS_LIBS ${APPKIT_LIBRARY} ${IOKIT_LIBRARY} ${OPENGL_LIBRARY} ${METAL_LIBRARY}
|
list(APPEND _BOO_SYS_LIBS ${APPKIT_LIBRARY} ${IOKIT_LIBRARY} ${OPENGL_LIBRARY} ${METAL_LIBRARY}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
#include "../mac/CocoaCommon.hpp"
|
||||||
|
#if BOO_HAS_METAL
|
||||||
#include <LogVisor/LogVisor.hpp>
|
#include <LogVisor/LogVisor.hpp>
|
||||||
#include "boo/graphicsdev/Metal.hpp"
|
#include "boo/graphicsdev/Metal.hpp"
|
||||||
#include "../mac/CocoaCommon.hpp"
|
|
||||||
#include "boo/IGraphicsContext.hpp"
|
#include "boo/IGraphicsContext.hpp"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -738,3 +739,5 @@ IGraphicsCommandQueue* _NewMetalCommandQueue(MetalContext* ctx, IWindow* parentW
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -95,6 +95,7 @@ public:
|
||||||
appDelegate->aboutPanel = aboutPanel;
|
appDelegate->aboutPanel = aboutPanel;
|
||||||
|
|
||||||
/* Determine which graphics API to use */
|
/* Determine which graphics API to use */
|
||||||
|
#if BOO_HAS_METAL
|
||||||
for (const SystemString& arg : args)
|
for (const SystemString& arg : args)
|
||||||
if (!arg.compare("--metal"))
|
if (!arg.compare("--metal"))
|
||||||
{
|
{
|
||||||
|
@ -102,6 +103,7 @@ public:
|
||||||
m_metalCtx.m_q = [m_metalCtx.m_dev.get() newCommandQueue];
|
m_metalCtx.m_q = [m_metalCtx.m_dev.get() newCommandQueue];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EPlatformType getPlatformType() const
|
EPlatformType getPlatformType() const
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
#define BOO_COCOACOMMON_HPP
|
#define BOO_COCOACOMMON_HPP
|
||||||
#if __APPLE__
|
#if __APPLE__
|
||||||
|
|
||||||
#include <Metal/Metal.h>
|
#include <Availability.h>
|
||||||
#include <QuartzCore/CAMetalLayer.h>
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class NSPtr
|
class NSPtr
|
||||||
|
@ -23,6 +22,12 @@ public:
|
||||||
void reset() {[m_ptr release]; m_ptr = 0;}
|
void reset() {[m_ptr release]; m_ptr = 0;}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101100
|
||||||
|
#define BOO_HAS_METAL 1
|
||||||
|
|
||||||
|
#include <Metal/Metal.h>
|
||||||
|
#include <QuartzCore/CAMetalLayer.h>
|
||||||
|
|
||||||
namespace boo
|
namespace boo
|
||||||
{
|
{
|
||||||
struct MetalContext
|
struct MetalContext
|
||||||
|
@ -37,5 +42,13 @@ struct MetalContext
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
#define BOO_HAS_METAL 0
|
||||||
|
namespace boo
|
||||||
|
{
|
||||||
|
struct MetalContext {};
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
#endif // BOO_COCOACOMMON_HPP
|
#endif // BOO_COCOACOMMON_HPP
|
||||||
|
|
|
@ -91,12 +91,12 @@ protected:
|
||||||
std::mutex m_dlmt;
|
std::mutex m_dlmt;
|
||||||
std::condition_variable m_dlcv;
|
std::condition_variable m_dlcv;
|
||||||
|
|
||||||
static CVReturn DLCallback(CVDisplayLinkRef CV_NONNULL displayLink,
|
static CVReturn DLCallback(CVDisplayLinkRef displayLink,
|
||||||
const CVTimeStamp * CV_NONNULL inNow,
|
const CVTimeStamp * inNow,
|
||||||
const CVTimeStamp * CV_NONNULL inOutputTime,
|
const CVTimeStamp * inOutputTime,
|
||||||
CVOptionFlags flagsIn,
|
CVOptionFlags flagsIn,
|
||||||
CVOptionFlags * CV_NONNULL flagsOut,
|
CVOptionFlags * flagsOut,
|
||||||
GraphicsContextCocoa* CV_NULLABLE ctx)
|
GraphicsContextCocoa* ctx)
|
||||||
{
|
{
|
||||||
ctx->m_dlcv.notify_one();
|
ctx->m_dlcv.notify_one();
|
||||||
return kCVReturnSuccess;
|
return kCVReturnSuccess;
|
||||||
|
@ -293,6 +293,7 @@ IGraphicsContext* _GraphicsContextCocoaGLNew(IGraphicsContext::EGraphicsAPI api,
|
||||||
return new GraphicsContextCocoaGL(api, parentWindow, lastGLCtx);
|
return new GraphicsContextCocoaGL(api, parentWindow, lastGLCtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if BOO_HAS_METAL
|
||||||
class GraphicsContextCocoaMetal : public GraphicsContextCocoa
|
class GraphicsContextCocoaMetal : public GraphicsContextCocoa
|
||||||
{
|
{
|
||||||
GraphicsContextCocoaMetalInternal* m_nsContext = nullptr;
|
GraphicsContextCocoaMetalInternal* m_nsContext = nullptr;
|
||||||
|
@ -392,6 +393,7 @@ IGraphicsContext* _GraphicsContextCocoaMetalNew(IGraphicsContext::EGraphicsAPI a
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return new GraphicsContextCocoaMetal(api, parentWindow, metalCtx);
|
return new GraphicsContextCocoaMetal(api, parentWindow, metalCtx);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -881,6 +883,7 @@ static boo::ESpecialKey translateKeycode(short code)
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
#if BOO_HAS_METAL
|
||||||
@implementation GraphicsContextCocoaMetalInternal
|
@implementation GraphicsContextCocoaMetalInternal
|
||||||
- (id)initWithBooContext:(boo::GraphicsContextCocoaMetal*)bctx
|
- (id)initWithBooContext:(boo::GraphicsContextCocoaMetal*)bctx
|
||||||
{
|
{
|
||||||
|
@ -922,6 +925,7 @@ static boo::ESpecialKey translateKeycode(short code)
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace boo
|
namespace boo
|
||||||
{
|
{
|
||||||
|
@ -939,9 +943,11 @@ public:
|
||||||
dispatch_sync(dispatch_get_main_queue(),
|
dispatch_sync(dispatch_get_main_queue(),
|
||||||
^{
|
^{
|
||||||
m_nsWindow = [[WindowCocoaInternal alloc] initWithBooWindow:this title:title];
|
m_nsWindow = [[WindowCocoaInternal alloc] initWithBooWindow:this title:title];
|
||||||
|
#if BOO_HAS_METAL
|
||||||
if (metalCtx->m_dev)
|
if (metalCtx->m_dev)
|
||||||
m_gfxCtx = _GraphicsContextCocoaMetalNew(IGraphicsContext::API_METAL, this, metalCtx);
|
m_gfxCtx = _GraphicsContextCocoaMetalNew(IGraphicsContext::API_METAL, this, metalCtx);
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
m_gfxCtx = _GraphicsContextCocoaGLNew(IGraphicsContext::API_OPENGL_3_3, this, lastGLCtx);
|
m_gfxCtx = _GraphicsContextCocoaGLNew(IGraphicsContext::API_OPENGL_3_3, this, lastGLCtx);
|
||||||
m_gfxCtx->initializeContext();
|
m_gfxCtx->initializeContext();
|
||||||
});
|
});
|
||||||
|
@ -1068,10 +1074,12 @@ public:
|
||||||
|
|
||||||
void setStyle(EWindowStyle style)
|
void setStyle(EWindowStyle style)
|
||||||
{
|
{
|
||||||
|
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
|
||||||
if (style & STYLE_TITLEBAR)
|
if (style & STYLE_TITLEBAR)
|
||||||
m_nsWindow.titleVisibility = NSWindowTitleVisible;
|
m_nsWindow.titleVisibility = NSWindowTitleVisible;
|
||||||
else
|
else
|
||||||
m_nsWindow.titleVisibility = NSWindowTitleHidden;
|
m_nsWindow.titleVisibility = NSWindowTitleHidden;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (style & STYLE_CLOSE)
|
if (style & STYLE_CLOSE)
|
||||||
m_nsWindow.styleMask |= NSClosableWindowMask;
|
m_nsWindow.styleMask |= NSClosableWindowMask;
|
||||||
|
@ -1087,7 +1095,11 @@ public:
|
||||||
EWindowStyle getStyle() const
|
EWindowStyle getStyle() const
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
|
||||||
retval |= m_nsWindow.titleVisibility == NSWindowTitleVisible ? STYLE_TITLEBAR : 0;
|
retval |= m_nsWindow.titleVisibility == NSWindowTitleVisible ? STYLE_TITLEBAR : 0;
|
||||||
|
#else
|
||||||
|
retval |= STYLE_TITLEBAR;
|
||||||
|
#endif
|
||||||
retval |= (m_nsWindow.styleMask & NSClosableWindowMask) ? STYLE_CLOSE : 0;
|
retval |= (m_nsWindow.styleMask & NSClosableWindowMask) ? STYLE_CLOSE : 0;
|
||||||
retval |= (m_nsWindow.styleMask & NSResizableWindowMask) ? STYLE_RESIZE: 0;
|
retval |= (m_nsWindow.styleMask & NSResizableWindowMask) ? STYLE_RESIZE: 0;
|
||||||
return EWindowStyle(retval);
|
return EWindowStyle(retval);
|
||||||
|
|
Loading…
Reference in New Issue