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