mirror of https://github.com/AxioDL/boo.git
OS X enum refactor fixes
This commit is contained in:
parent
c9edf8dd85
commit
d040e20096
|
@ -173,18 +173,7 @@ enum class EWindowStyle
|
||||||
|
|
||||||
Default = Titlebar | Resize | Close
|
Default = Titlebar | Resize | Close
|
||||||
};
|
};
|
||||||
|
ENABLE_BITWISE_ENUM(EWindowStyle)
|
||||||
inline EWindowStyle operator|(EWindowStyle a, EWindowStyle b)
|
|
||||||
{
|
|
||||||
using T = std::underlying_type_t<EWindowStyle>;
|
|
||||||
return EWindowStyle(static_cast<T>(a) | static_cast<T>(b));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline EWindowStyle operator&(EWindowStyle a, EWindowStyle b)
|
|
||||||
{
|
|
||||||
using T = std::underlying_type_t<EWindowStyle>;
|
|
||||||
return EWindowStyle(static_cast<T>(a) & static_cast<T>(b));
|
|
||||||
}
|
|
||||||
|
|
||||||
class IWindow
|
class IWindow
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
#ifndef GDEV_METAL_HPP
|
#ifndef GDEV_METAL_HPP
|
||||||
#define GDEV_METAL_HPP
|
#define GDEV_METAL_HPP
|
||||||
|
#ifdef __APPLE__
|
||||||
|
|
||||||
|
#include <Availability.h>
|
||||||
|
|
||||||
|
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101100
|
||||||
|
#define BOO_HAS_METAL 1
|
||||||
|
|
||||||
#include "IGraphicsDataFactory.hpp"
|
#include "IGraphicsDataFactory.hpp"
|
||||||
#include "IGraphicsCommandQueue.hpp"
|
#include "IGraphicsCommandQueue.hpp"
|
||||||
|
@ -22,7 +28,7 @@ public:
|
||||||
MetalDataFactory(IGraphicsContext* parent, MetalContext* ctx);
|
MetalDataFactory(IGraphicsContext* parent, MetalContext* ctx);
|
||||||
~MetalDataFactory() {}
|
~MetalDataFactory() {}
|
||||||
|
|
||||||
Platform platform() const {return PlatformMetal;}
|
Platform platform() const {return Platform::Metal;}
|
||||||
const char* platformName() const {return "Metal";}
|
const char* platformName() const {return "Metal";}
|
||||||
|
|
||||||
IGraphicsBufferS* newStaticBuffer(BufferUse use, const void* data, size_t stride, size_t count);
|
IGraphicsBufferS* newStaticBuffer(BufferUse use, const void* data, size_t stride, size_t count);
|
||||||
|
@ -59,4 +65,9 @@ public:
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
#define BOO_HAS_METAL 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // __APPLE__
|
||||||
#endif // GDEV_METAL_HPP
|
#endif // GDEV_METAL_HPP
|
||||||
|
|
|
@ -247,7 +247,7 @@ struct MetalVertexFormat : IVertexFormat
|
||||||
for (size_t i=0 ; i<elementCount ; ++i)
|
for (size_t i=0 ; i<elementCount ; ++i)
|
||||||
{
|
{
|
||||||
const VertexElementDescriptor* elemin = &elements[i];
|
const VertexElementDescriptor* elemin = &elements[i];
|
||||||
stride += SEMANTIC_SIZE_TABLE[elemin->semantic];
|
stride += SEMANTIC_SIZE_TABLE[int(elemin->semantic)];
|
||||||
}
|
}
|
||||||
|
|
||||||
m_vdesc = [MTLVertexDescriptor vertexDescriptor];
|
m_vdesc = [MTLVertexDescriptor vertexDescriptor];
|
||||||
|
@ -261,10 +261,10 @@ struct MetalVertexFormat : IVertexFormat
|
||||||
{
|
{
|
||||||
const VertexElementDescriptor* elemin = &elements[i];
|
const VertexElementDescriptor* elemin = &elements[i];
|
||||||
MTLVertexAttributeDescriptor* attrDesc = m_vdesc.get().attributes[i];
|
MTLVertexAttributeDescriptor* attrDesc = m_vdesc.get().attributes[i];
|
||||||
attrDesc.format = SEMANTIC_TYPE_TABLE[elemin->semantic];
|
attrDesc.format = SEMANTIC_TYPE_TABLE[int(elemin->semantic)];
|
||||||
attrDesc.offset = offset;
|
attrDesc.offset = offset;
|
||||||
attrDesc.bufferIndex = 0;
|
attrDesc.bufferIndex = 0;
|
||||||
offset += SEMANTIC_SIZE_TABLE[elemin->semantic];
|
offset += SEMANTIC_SIZE_TABLE[int(elemin->semantic)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -302,9 +302,9 @@ class MetalShaderPipeline : public IShaderPipeline
|
||||||
desc.get().vertexDescriptor = vtxFmt->m_vdesc.get();
|
desc.get().vertexDescriptor = vtxFmt->m_vdesc.get();
|
||||||
desc.get().sampleCount = target->samples();
|
desc.get().sampleCount = target->samples();
|
||||||
desc.get().colorAttachments[0].pixelFormat = MTLPixelFormatBGRA8Unorm;
|
desc.get().colorAttachments[0].pixelFormat = MTLPixelFormatBGRA8Unorm;
|
||||||
desc.get().colorAttachments[0].blendingEnabled = dstFac != BlendFactorZero;
|
desc.get().colorAttachments[0].blendingEnabled = dstFac != BlendFactor::Zero;
|
||||||
desc.get().colorAttachments[0].sourceRGBBlendFactor = BLEND_FACTOR_TABLE[srcFac];
|
desc.get().colorAttachments[0].sourceRGBBlendFactor = BLEND_FACTOR_TABLE[int(srcFac)];
|
||||||
desc.get().colorAttachments[0].destinationRGBBlendFactor = BLEND_FACTOR_TABLE[dstFac];
|
desc.get().colorAttachments[0].destinationRGBBlendFactor = BLEND_FACTOR_TABLE[int(dstFac)];
|
||||||
desc.get().depthAttachmentPixelFormat = MTLPixelFormatDepth32Float;
|
desc.get().depthAttachmentPixelFormat = MTLPixelFormatDepth32Float;
|
||||||
desc.get().inputPrimitiveTopology = MTLPrimitiveTopologyClassTriangle;
|
desc.get().inputPrimitiveTopology = MTLPrimitiveTopologyClassTriangle;
|
||||||
NSError* err = nullptr;
|
NSError* err = nullptr;
|
||||||
|
@ -350,17 +350,17 @@ static id<MTLBuffer> GetBufferGPUResource(const IGraphicsBuffer* buf, int idx)
|
||||||
|
|
||||||
static id<MTLTexture> GetTextureGPUResource(const ITexture* tex, int idx)
|
static id<MTLTexture> GetTextureGPUResource(const ITexture* tex, int idx)
|
||||||
{
|
{
|
||||||
if (tex->type() == ITexture::TextureDynamic)
|
if (tex->type() == TextureType::Dynamic)
|
||||||
{
|
{
|
||||||
const MetalTextureD* ctex = static_cast<const MetalTextureD*>(tex);
|
const MetalTextureD* ctex = static_cast<const MetalTextureD*>(tex);
|
||||||
return ctex->m_texs[idx].get();
|
return ctex->m_texs[idx].get();
|
||||||
}
|
}
|
||||||
else if (tex->type() == ITexture::TextureStatic)
|
else if (tex->type() == TextureType::Static)
|
||||||
{
|
{
|
||||||
const MetalTextureS* ctex = static_cast<const MetalTextureS*>(tex);
|
const MetalTextureS* ctex = static_cast<const MetalTextureS*>(tex);
|
||||||
return ctex->m_tex.get();
|
return ctex->m_tex.get();
|
||||||
}
|
}
|
||||||
else if (tex->type() == ITexture::TextureRender)
|
else if (tex->type() == TextureType::Render)
|
||||||
{
|
{
|
||||||
const MetalTextureR* ctex = static_cast<const MetalTextureR*>(tex);
|
const MetalTextureR* ctex = static_cast<const MetalTextureR*>(tex);
|
||||||
return ctex->m_tex.get();
|
return ctex->m_tex.get();
|
||||||
|
@ -409,7 +409,7 @@ struct MetalShaderDataBinding : IShaderDataBinding
|
||||||
|
|
||||||
struct MetalCommandQueue : IGraphicsCommandQueue
|
struct MetalCommandQueue : IGraphicsCommandQueue
|
||||||
{
|
{
|
||||||
Platform platform() const {return IGraphicsDataFactory::PlatformMetal;}
|
Platform platform() const {return IGraphicsDataFactory::Platform::Metal;}
|
||||||
const char* platformName() const {return "Metal";}
|
const char* platformName() const {return "Metal";}
|
||||||
MetalContext* m_ctx;
|
MetalContext* m_ctx;
|
||||||
IWindow* m_parentWindow;
|
IWindow* m_parentWindow;
|
||||||
|
@ -484,9 +484,9 @@ struct MetalCommandQueue : IGraphicsCommandQueue
|
||||||
MTLPrimitiveType m_primType = MTLPrimitiveTypeTriangle;
|
MTLPrimitiveType m_primType = MTLPrimitiveTypeTriangle;
|
||||||
void setDrawPrimitive(Primitive prim)
|
void setDrawPrimitive(Primitive prim)
|
||||||
{
|
{
|
||||||
if (prim == PrimitiveTriangles)
|
if (prim == Primitive::Triangles)
|
||||||
m_primType = MTLPrimitiveTypeTriangle;
|
m_primType = MTLPrimitiveTypeTriangle;
|
||||||
else if (prim == PrimitiveTriStrips)
|
else if (prim == Primitive::TriStrips)
|
||||||
m_primType = MTLPrimitiveTypeTriangleStrip;
|
m_primType = MTLPrimitiveTypeTriangleStrip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -226,12 +226,12 @@ public:
|
||||||
{
|
{
|
||||||
devImp.m_hidDev = this;
|
devImp.m_hidDev = this;
|
||||||
std::unique_lock<std::mutex> lk(m_initMutex);
|
std::unique_lock<std::mutex> lk(m_initMutex);
|
||||||
DeviceToken::TDeviceType dType = token.getDeviceType();
|
DeviceToken::DeviceType dType = token.getDeviceType();
|
||||||
if (dType == DeviceToken::DEVTYPE_USB)
|
if (dType == DeviceToken::DeviceType::USB)
|
||||||
m_thread = new std::thread(_threadProcUSBLL, this);
|
m_thread = new std::thread(_threadProcUSBLL, this);
|
||||||
else if (dType == DeviceToken::DEVTYPE_BLUETOOTH)
|
else if (dType == DeviceToken::DeviceType::Bluetooth)
|
||||||
m_thread = new std::thread(_threadProcBTLL, this);
|
m_thread = new std::thread(_threadProcBTLL, this);
|
||||||
else if (dType == DeviceToken::DEVTYPE_GENERICHID)
|
else if (dType == DeviceToken::DeviceType::GenericHID)
|
||||||
m_thread = new std::thread(_threadProcHID, this);
|
m_thread = new std::thread(_threadProcHID, this);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -111,7 +111,7 @@ class HIDListenerIOKit : public IHIDListener
|
||||||
getUSBStringDescriptor(dev, vstridx, vstr);
|
getUSBStringDescriptor(dev, vstridx, vstr);
|
||||||
getUSBStringDescriptor(dev, pstridx, pstr);
|
getUSBStringDescriptor(dev, pstridx, pstr);
|
||||||
|
|
||||||
if (!listener->m_finder._insertToken(DeviceToken(DeviceToken::DEVTYPE_USB,
|
if (!listener->m_finder._insertToken(DeviceToken(DeviceToken::DeviceType::USB,
|
||||||
vid, pid, vstr, pstr, devPath)))
|
vid, pid, vstr, pstr, devPath)))
|
||||||
{
|
{
|
||||||
/* Matched-insertion failed; see if generic HID interface is available */
|
/* Matched-insertion failed; see if generic HID interface is available */
|
||||||
|
|
|
@ -116,7 +116,7 @@ public:
|
||||||
|
|
||||||
EPlatformType getPlatformType() const
|
EPlatformType getPlatformType() const
|
||||||
{
|
{
|
||||||
return PLAT_COCOA;
|
return EPlatformType::Cocoa;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::thread m_clientThread;
|
std::thread m_clientThread;
|
||||||
|
@ -192,8 +192,8 @@ int ApplicationRun(IApplication::EPlatformType platform,
|
||||||
{
|
{
|
||||||
if (!APP)
|
if (!APP)
|
||||||
{
|
{
|
||||||
if (platform != IApplication::PLAT_COCOA &&
|
if (platform != IApplication::EPlatformType::Cocoa &&
|
||||||
platform != IApplication::PLAT_AUTO)
|
platform != IApplication::EPlatformType::Auto)
|
||||||
return 1;
|
return 1;
|
||||||
APP = new ApplicationCocoa(cb, uniqueName, friendlyName, pname, args);
|
APP = new ApplicationCocoa(cb, uniqueName, friendlyName, pname, args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,7 @@ public:
|
||||||
NSOpenGLContext* m_lastCtx = nullptr;
|
NSOpenGLContext* m_lastCtx = nullptr;
|
||||||
|
|
||||||
GraphicsContextCocoaGL(EGraphicsAPI api, IWindow* parentWindow, NSOpenGLContext* lastGLCtx)
|
GraphicsContextCocoaGL(EGraphicsAPI api, IWindow* parentWindow, NSOpenGLContext* lastGLCtx)
|
||||||
: GraphicsContextCocoa(api, PF_RGBA8, parentWindow),
|
: GraphicsContextCocoa(api, EPixelFormat::RGBA8, parentWindow),
|
||||||
m_lastCtx(lastGLCtx)
|
m_lastCtx(lastGLCtx)
|
||||||
{
|
{
|
||||||
m_dataFactory = new GLDataFactory(this);
|
m_dataFactory = new GLDataFactory(this);
|
||||||
|
@ -200,7 +200,7 @@ public:
|
||||||
|
|
||||||
void setPixelFormat(EPixelFormat pf)
|
void setPixelFormat(EPixelFormat pf)
|
||||||
{
|
{
|
||||||
if (pf > PF_RGBAF32_Z24)
|
if (pf > EPixelFormat::RGBAF32_Z24)
|
||||||
return;
|
return;
|
||||||
m_pf = pf;
|
m_pf = pf;
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ public:
|
||||||
{
|
{
|
||||||
if (!m_mainCtx)
|
if (!m_mainCtx)
|
||||||
{
|
{
|
||||||
NSOpenGLPixelFormat* nspf = [[NSOpenGLPixelFormat alloc] initWithAttributes:PF_TABLE[m_pf]];
|
NSOpenGLPixelFormat* nspf = [[NSOpenGLPixelFormat alloc] initWithAttributes:PF_TABLE[int(m_pf)]];
|
||||||
m_mainCtx = [[NSOpenGLContext alloc] initWithFormat:nspf shareContext:[m_nsContext openGLContext]];
|
m_mainCtx = [[NSOpenGLContext alloc] initWithFormat:nspf shareContext:[m_nsContext openGLContext]];
|
||||||
[nspf release];
|
[nspf release];
|
||||||
if (!m_mainCtx)
|
if (!m_mainCtx)
|
||||||
|
@ -254,7 +254,7 @@ public:
|
||||||
{
|
{
|
||||||
if (!m_loadCtx)
|
if (!m_loadCtx)
|
||||||
{
|
{
|
||||||
NSOpenGLPixelFormat* nspf = [[NSOpenGLPixelFormat alloc] initWithAttributes:PF_TABLE[m_pf]];
|
NSOpenGLPixelFormat* nspf = [[NSOpenGLPixelFormat alloc] initWithAttributes:PF_TABLE[int(m_pf)]];
|
||||||
m_loadCtx = [[NSOpenGLContext alloc] initWithFormat:nspf shareContext:[m_nsContext openGLContext]];
|
m_loadCtx = [[NSOpenGLContext alloc] initWithFormat:nspf shareContext:[m_nsContext openGLContext]];
|
||||||
[nspf release];
|
[nspf release];
|
||||||
if (!m_loadCtx)
|
if (!m_loadCtx)
|
||||||
|
@ -274,7 +274,7 @@ public:
|
||||||
IGraphicsContext* _GraphicsContextCocoaGLNew(IGraphicsContext::EGraphicsAPI api,
|
IGraphicsContext* _GraphicsContextCocoaGLNew(IGraphicsContext::EGraphicsAPI api,
|
||||||
IWindow* parentWindow, NSOpenGLContext* lastGLCtx)
|
IWindow* parentWindow, NSOpenGLContext* lastGLCtx)
|
||||||
{
|
{
|
||||||
if (api != IGraphicsContext::API_OPENGL_3_3 && api != IGraphicsContext::API_OPENGL_4_2)
|
if (api != IGraphicsContext::EGraphicsAPI::OpenGL3_3 && api != IGraphicsContext::EGraphicsAPI::OpenGL4_2)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Create temporary context to query GL version */
|
/* Create temporary context to query GL version */
|
||||||
|
@ -300,9 +300,9 @@ IGraphicsContext* _GraphicsContextCocoaGLNew(IGraphicsContext::EGraphicsAPI api,
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (major > 4 || (major == 4 && minor >= 2))
|
if (major > 4 || (major == 4 && minor >= 2))
|
||||||
api = IGraphicsContext::API_OPENGL_4_2;
|
api = IGraphicsContext::EGraphicsAPI::OpenGL4_2;
|
||||||
else if (major == 3 && minor >= 3)
|
else if (major == 3 && minor >= 3)
|
||||||
if (api == IGraphicsContext::API_OPENGL_4_2)
|
if (api == IGraphicsContext::EGraphicsAPI::OpenGL4_2)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return new GraphicsContextCocoaGL(api, parentWindow, lastGLCtx);
|
return new GraphicsContextCocoaGL(api, parentWindow, lastGLCtx);
|
||||||
|
@ -321,7 +321,7 @@ public:
|
||||||
|
|
||||||
GraphicsContextCocoaMetal(EGraphicsAPI api, IWindow* parentWindow,
|
GraphicsContextCocoaMetal(EGraphicsAPI api, IWindow* parentWindow,
|
||||||
MetalContext* metalCtx)
|
MetalContext* metalCtx)
|
||||||
: GraphicsContextCocoa(api, PF_RGBA8, parentWindow),
|
: GraphicsContextCocoa(api, EPixelFormat::RGBA8, parentWindow),
|
||||||
m_metalCtx(metalCtx)
|
m_metalCtx(metalCtx)
|
||||||
{
|
{
|
||||||
m_dataFactory = new MetalDataFactory(this, metalCtx);
|
m_dataFactory = new MetalDataFactory(this, metalCtx);
|
||||||
|
@ -352,7 +352,7 @@ public:
|
||||||
|
|
||||||
void setPixelFormat(EPixelFormat pf)
|
void setPixelFormat(EPixelFormat pf)
|
||||||
{
|
{
|
||||||
if (pf > PF_RGBAF32_Z24)
|
if (pf > EPixelFormat::RGBAF32_Z24)
|
||||||
return;
|
return;
|
||||||
m_pf = pf;
|
m_pf = pf;
|
||||||
}
|
}
|
||||||
|
@ -409,7 +409,7 @@ IGraphicsContext* _GraphicsContextCocoaMetalNew(IGraphicsContext::EGraphicsAPI a
|
||||||
IWindow* parentWindow,
|
IWindow* parentWindow,
|
||||||
MetalContext* metalCtx)
|
MetalContext* metalCtx)
|
||||||
{
|
{
|
||||||
if (api != IGraphicsContext::API_METAL)
|
if (api != IGraphicsContext::EGraphicsAPI::Metal)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return new GraphicsContextCocoaMetal(api, parentWindow, metalCtx);
|
return new GraphicsContextCocoaMetal(api, parentWindow, metalCtx);
|
||||||
}
|
}
|
||||||
|
@ -428,28 +428,28 @@ IGraphicsContext* _GraphicsContextCocoaMetalNew(IGraphicsContext::EGraphicsAPI a
|
||||||
|
|
||||||
static inline boo::EModifierKey getMod(NSUInteger flags)
|
static inline boo::EModifierKey getMod(NSUInteger flags)
|
||||||
{
|
{
|
||||||
int ret = boo::MKEY_NONE;
|
boo::EModifierKey ret = boo::EModifierKey::None;
|
||||||
if (flags & NSControlKeyMask)
|
if (flags & NSControlKeyMask)
|
||||||
ret |= boo::MKEY_CTRL;
|
ret |= boo::EModifierKey::Ctrl;
|
||||||
if (flags & NSAlternateKeyMask)
|
if (flags & NSAlternateKeyMask)
|
||||||
ret |= boo::MKEY_ALT;
|
ret |= boo::EModifierKey::Alt;
|
||||||
if (flags & NSShiftKeyMask)
|
if (flags & NSShiftKeyMask)
|
||||||
ret |= boo::MKEY_SHIFT;
|
ret |= boo::EModifierKey::Shift;
|
||||||
if (flags & NSCommandKeyMask)
|
if (flags & NSCommandKeyMask)
|
||||||
ret |= boo::MKEY_COMMAND;
|
ret |= boo::EModifierKey::Command;
|
||||||
return static_cast<boo::EModifierKey>(ret);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline boo::EMouseButton getButton(NSEvent* event)
|
static inline boo::EMouseButton getButton(NSEvent* event)
|
||||||
{
|
{
|
||||||
NSInteger buttonNumber = event.buttonNumber;
|
NSInteger buttonNumber = event.buttonNumber;
|
||||||
if (buttonNumber == 3)
|
if (buttonNumber == 3)
|
||||||
return boo::BUTTON_MIDDLE;
|
return boo::EMouseButton::Middle;
|
||||||
else if (buttonNumber == 4)
|
else if (buttonNumber == 4)
|
||||||
return boo::BUTTON_AUX1;
|
return boo::EMouseButton::Aux1;
|
||||||
else if (buttonNumber == 5)
|
else if (buttonNumber == 5)
|
||||||
return boo::BUTTON_AUX2;
|
return boo::EMouseButton::Aux2;
|
||||||
return boo::BUTTON_NONE;
|
return boo::EMouseButton::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)mouseDown:(NSEvent*)theEvent
|
- (void)mouseDown:(NSEvent*)theEvent
|
||||||
|
@ -465,7 +465,7 @@ static inline boo::EMouseButton getButton(NSEvent* event)
|
||||||
{(unsigned)liw.x, (unsigned)liw.y},
|
{(unsigned)liw.x, (unsigned)liw.y},
|
||||||
{(float)(liw.x / frame.size.width), (float)(liw.y / frame.size.height)}
|
{(float)(liw.x / frame.size.width), (float)(liw.y / frame.size.height)}
|
||||||
};
|
};
|
||||||
booContext->m_callback->mouseDown(coord, boo::BUTTON_PRIMARY,
|
booContext->m_callback->mouseDown(coord, boo::EMouseButton::Primary,
|
||||||
getMod([theEvent modifierFlags]));
|
getMod([theEvent modifierFlags]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -482,7 +482,7 @@ static inline boo::EMouseButton getButton(NSEvent* event)
|
||||||
{(unsigned)liw.x, (unsigned)liw.y},
|
{(unsigned)liw.x, (unsigned)liw.y},
|
||||||
{(float)(liw.x / frame.size.width), (float)(liw.y / frame.size.height)}
|
{(float)(liw.x / frame.size.width), (float)(liw.y / frame.size.height)}
|
||||||
};
|
};
|
||||||
booContext->m_callback->mouseUp(coord, boo::BUTTON_PRIMARY,
|
booContext->m_callback->mouseUp(coord, boo::EMouseButton::Primary,
|
||||||
getMod([theEvent modifierFlags]));
|
getMod([theEvent modifierFlags]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,7 +499,7 @@ static inline boo::EMouseButton getButton(NSEvent* event)
|
||||||
{(unsigned)liw.x, (unsigned)liw.y},
|
{(unsigned)liw.x, (unsigned)liw.y},
|
||||||
{(float)(liw.x / frame.size.width), (float)(liw.y / frame.size.height)}
|
{(float)(liw.x / frame.size.width), (float)(liw.y / frame.size.height)}
|
||||||
};
|
};
|
||||||
booContext->m_callback->mouseDown(coord, boo::BUTTON_SECONDARY,
|
booContext->m_callback->mouseDown(coord, boo::EMouseButton::Secondary,
|
||||||
getMod([theEvent modifierFlags]));
|
getMod([theEvent modifierFlags]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -516,7 +516,7 @@ static inline boo::EMouseButton getButton(NSEvent* event)
|
||||||
{(unsigned)liw.x, (unsigned)liw.y},
|
{(unsigned)liw.x, (unsigned)liw.y},
|
||||||
{(float)(liw.x / frame.size.width), (float)(liw.y / frame.size.height)}
|
{(float)(liw.x / frame.size.width), (float)(liw.y / frame.size.height)}
|
||||||
};
|
};
|
||||||
booContext->m_callback->mouseUp(coord, boo::BUTTON_SECONDARY,
|
booContext->m_callback->mouseUp(coord, boo::EMouseButton::Secondary,
|
||||||
getMod([theEvent modifierFlags]));
|
getMod([theEvent modifierFlags]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,7 +525,7 @@ static inline boo::EMouseButton getButton(NSEvent* event)
|
||||||
if (!booContext->m_callback)
|
if (!booContext->m_callback)
|
||||||
return;
|
return;
|
||||||
boo::EMouseButton button = getButton(theEvent);
|
boo::EMouseButton button = getButton(theEvent);
|
||||||
if (!button)
|
if (button == boo::EMouseButton::None)
|
||||||
return;
|
return;
|
||||||
NSPoint liw = [parentView convertPoint:[theEvent locationInWindow] fromView:nil];
|
NSPoint liw = [parentView convertPoint:[theEvent locationInWindow] fromView:nil];
|
||||||
float pixelFactor = [[parentView window] backingScaleFactor];
|
float pixelFactor = [[parentView window] backingScaleFactor];
|
||||||
|
@ -544,7 +544,7 @@ static inline boo::EMouseButton getButton(NSEvent* event)
|
||||||
if (!booContext->m_callback)
|
if (!booContext->m_callback)
|
||||||
return;
|
return;
|
||||||
boo::EMouseButton button = getButton(theEvent);
|
boo::EMouseButton button = getButton(theEvent);
|
||||||
if (!button)
|
if (button == boo::EMouseButton::None)
|
||||||
return;
|
return;
|
||||||
NSPoint liw = [parentView convertPoint:[theEvent locationInWindow] fromView:nil];
|
NSPoint liw = [parentView convertPoint:[theEvent locationInWindow] fromView:nil];
|
||||||
float pixelFactor = [[parentView window] backingScaleFactor];
|
float pixelFactor = [[parentView window] backingScaleFactor];
|
||||||
|
@ -728,55 +728,55 @@ static boo::ESpecialKey translateKeycode(short code)
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case kVK_F1:
|
case kVK_F1:
|
||||||
return boo::KEY_F1;
|
return boo::ESpecialKey::F1;
|
||||||
case kVK_F2:
|
case kVK_F2:
|
||||||
return boo::KEY_F2;
|
return boo::ESpecialKey::F2;
|
||||||
case kVK_F3:
|
case kVK_F3:
|
||||||
return boo::KEY_F3;
|
return boo::ESpecialKey::F3;
|
||||||
case kVK_F4:
|
case kVK_F4:
|
||||||
return boo::KEY_F4;
|
return boo::ESpecialKey::F4;
|
||||||
case kVK_F5:
|
case kVK_F5:
|
||||||
return boo::KEY_F5;
|
return boo::ESpecialKey::F5;
|
||||||
case kVK_F6:
|
case kVK_F6:
|
||||||
return boo::KEY_F6;
|
return boo::ESpecialKey::F6;
|
||||||
case kVK_F7:
|
case kVK_F7:
|
||||||
return boo::KEY_F7;
|
return boo::ESpecialKey::F7;
|
||||||
case kVK_F8:
|
case kVK_F8:
|
||||||
return boo::KEY_F8;
|
return boo::ESpecialKey::F8;
|
||||||
case kVK_F9:
|
case kVK_F9:
|
||||||
return boo::KEY_F9;
|
return boo::ESpecialKey::F9;
|
||||||
case kVK_F10:
|
case kVK_F10:
|
||||||
return boo::KEY_F10;
|
return boo::ESpecialKey::F10;
|
||||||
case kVK_F11:
|
case kVK_F11:
|
||||||
return boo::KEY_F11;
|
return boo::ESpecialKey::F11;
|
||||||
case kVK_F12:
|
case kVK_F12:
|
||||||
return boo::KEY_F12;
|
return boo::ESpecialKey::F12;
|
||||||
case kVK_Escape:
|
case kVK_Escape:
|
||||||
return boo::KEY_ESC;
|
return boo::ESpecialKey::Esc;
|
||||||
case kVK_Return:
|
case kVK_Return:
|
||||||
return boo::KEY_ENTER;
|
return boo::ESpecialKey::Enter;
|
||||||
case kVK_Delete:
|
case kVK_Delete:
|
||||||
return boo::KEY_BACKSPACE;
|
return boo::ESpecialKey::Backspace;
|
||||||
case kVK_ForwardDelete:
|
case kVK_ForwardDelete:
|
||||||
return boo::KEY_DELETE;
|
return boo::ESpecialKey::Delete;
|
||||||
case kVK_Home:
|
case kVK_Home:
|
||||||
return boo::KEY_HOME;
|
return boo::ESpecialKey::Home;
|
||||||
case kVK_End:
|
case kVK_End:
|
||||||
return boo::KEY_END;
|
return boo::ESpecialKey::End;
|
||||||
case kVK_PageUp:
|
case kVK_PageUp:
|
||||||
return boo::KEY_PGUP;
|
return boo::ESpecialKey::PgUp;
|
||||||
case kVK_PageDown:
|
case kVK_PageDown:
|
||||||
return boo::KEY_PGDOWN;
|
return boo::ESpecialKey::PgDown;
|
||||||
case kVK_LeftArrow:
|
case kVK_LeftArrow:
|
||||||
return boo::KEY_LEFT;
|
return boo::ESpecialKey::Left;
|
||||||
case kVK_RightArrow:
|
case kVK_RightArrow:
|
||||||
return boo::KEY_RIGHT;
|
return boo::ESpecialKey::Right;
|
||||||
case kVK_UpArrow:
|
case kVK_UpArrow:
|
||||||
return boo::KEY_UP;
|
return boo::ESpecialKey::Up;
|
||||||
case kVK_DownArrow:
|
case kVK_DownArrow:
|
||||||
return boo::KEY_DOWN;
|
return boo::ESpecialKey::Down;
|
||||||
default:
|
default:
|
||||||
return boo::KEY_NONE;
|
return boo::ESpecialKey::None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -821,23 +821,23 @@ static boo::ESpecialKey translateKeycode(short code)
|
||||||
|
|
||||||
NSUInteger downFlags = changedFlags & modFlags;
|
NSUInteger downFlags = changedFlags & modFlags;
|
||||||
if (downFlags & NSControlKeyMask)
|
if (downFlags & NSControlKeyMask)
|
||||||
booContext->m_callback->modKeyDown(boo::MKEY_CTRL, false);
|
booContext->m_callback->modKeyDown(boo::EModifierKey::Ctrl, false);
|
||||||
if (downFlags & NSAlternateKeyMask)
|
if (downFlags & NSAlternateKeyMask)
|
||||||
booContext->m_callback->modKeyDown(boo::MKEY_ALT, false);
|
booContext->m_callback->modKeyDown(boo::EModifierKey::Alt, false);
|
||||||
if (downFlags & NSShiftKeyMask)
|
if (downFlags & NSShiftKeyMask)
|
||||||
booContext->m_callback->modKeyDown(boo::MKEY_SHIFT, false);
|
booContext->m_callback->modKeyDown(boo::EModifierKey::Shift, false);
|
||||||
if (downFlags & NSCommandKeyMask)
|
if (downFlags & NSCommandKeyMask)
|
||||||
booContext->m_callback->modKeyDown(boo::MKEY_COMMAND, false);
|
booContext->m_callback->modKeyDown(boo::EModifierKey::Command, false);
|
||||||
|
|
||||||
NSUInteger upFlags = changedFlags & ~modFlags;
|
NSUInteger upFlags = changedFlags & ~modFlags;
|
||||||
if (upFlags & NSControlKeyMask)
|
if (upFlags & NSControlKeyMask)
|
||||||
booContext->m_callback->modKeyUp(boo::MKEY_CTRL);
|
booContext->m_callback->modKeyUp(boo::EModifierKey::Ctrl);
|
||||||
if (upFlags & NSAlternateKeyMask)
|
if (upFlags & NSAlternateKeyMask)
|
||||||
booContext->m_callback->modKeyUp(boo::MKEY_ALT);
|
booContext->m_callback->modKeyUp(boo::EModifierKey::Alt);
|
||||||
if (upFlags & NSShiftKeyMask)
|
if (upFlags & NSShiftKeyMask)
|
||||||
booContext->m_callback->modKeyUp(boo::MKEY_SHIFT);
|
booContext->m_callback->modKeyUp(boo::EModifierKey::Shift);
|
||||||
if (upFlags & NSCommandKeyMask)
|
if (upFlags & NSCommandKeyMask)
|
||||||
booContext->m_callback->modKeyUp(boo::MKEY_COMMAND);
|
booContext->m_callback->modKeyUp(boo::EModifierKey::Command);
|
||||||
|
|
||||||
lastModifiers = modFlags;
|
lastModifiers = modFlags;
|
||||||
}
|
}
|
||||||
|
@ -860,7 +860,7 @@ static boo::ESpecialKey translateKeycode(short code)
|
||||||
{
|
{
|
||||||
resp = [[BooCocoaResponder alloc] initWithBooContext:bctx View:self];
|
resp = [[BooCocoaResponder alloc] initWithBooContext:bctx View:self];
|
||||||
boo::IGraphicsContext::EPixelFormat pf = bctx->getPixelFormat();
|
boo::IGraphicsContext::EPixelFormat pf = bctx->getPixelFormat();
|
||||||
NSOpenGLPixelFormat* nspf = [[NSOpenGLPixelFormat alloc] initWithAttributes:PF_TABLE[pf]];
|
NSOpenGLPixelFormat* nspf = [[NSOpenGLPixelFormat alloc] initWithAttributes:PF_TABLE[int(pf)]];
|
||||||
self = [self initWithFrame:NSMakeRect(0, 0, 100, 100) pixelFormat:nspf];
|
self = [self initWithFrame:NSMakeRect(0, 0, 100, 100) pixelFormat:nspf];
|
||||||
if (bctx->m_lastCtx)
|
if (bctx->m_lastCtx)
|
||||||
{
|
{
|
||||||
|
@ -965,10 +965,10 @@ public:
|
||||||
m_nsWindow = [[WindowCocoaInternal alloc] initWithBooWindow:this title:title];
|
m_nsWindow = [[WindowCocoaInternal alloc] initWithBooWindow:this title:title];
|
||||||
#if BOO_HAS_METAL
|
#if BOO_HAS_METAL
|
||||||
if (metalCtx->m_dev)
|
if (metalCtx->m_dev)
|
||||||
m_gfxCtx = _GraphicsContextCocoaMetalNew(IGraphicsContext::API_METAL, this, metalCtx);
|
m_gfxCtx = _GraphicsContextCocoaMetalNew(IGraphicsContext::EGraphicsAPI::Metal, this, metalCtx);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
m_gfxCtx = _GraphicsContextCocoaGLNew(IGraphicsContext::API_OPENGL_3_3, this, lastGLCtx);
|
m_gfxCtx = _GraphicsContextCocoaGLNew(IGraphicsContext::EGraphicsAPI::OpenGL3_3, this, lastGLCtx);
|
||||||
m_gfxCtx->initializeContext();
|
m_gfxCtx->initializeContext();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1089,24 +1089,24 @@ public:
|
||||||
|
|
||||||
ETouchType getTouchType() const
|
ETouchType getTouchType() const
|
||||||
{
|
{
|
||||||
return TOUCH_TRACKPAD;
|
return ETouchType::Trackpad;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setStyle(EWindowStyle style)
|
void setStyle(EWindowStyle style)
|
||||||
{
|
{
|
||||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
|
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
|
||||||
if (style & STYLE_TITLEBAR)
|
if ((style & EWindowStyle::Titlebar) != EWindowStyle::None)
|
||||||
m_nsWindow.titleVisibility = NSWindowTitleVisible;
|
m_nsWindow.titleVisibility = NSWindowTitleVisible;
|
||||||
else
|
else
|
||||||
m_nsWindow.titleVisibility = NSWindowTitleHidden;
|
m_nsWindow.titleVisibility = NSWindowTitleHidden;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (style & STYLE_CLOSE)
|
if ((style & EWindowStyle::Close) != EWindowStyle::None)
|
||||||
m_nsWindow.styleMask |= NSClosableWindowMask;
|
m_nsWindow.styleMask |= NSClosableWindowMask;
|
||||||
else
|
else
|
||||||
m_nsWindow.styleMask &= ~NSClosableWindowMask;
|
m_nsWindow.styleMask &= ~NSClosableWindowMask;
|
||||||
|
|
||||||
if (style & STYLE_RESIZE)
|
if ((style & EWindowStyle::Resize) != EWindowStyle::None)
|
||||||
m_nsWindow.styleMask |= NSResizableWindowMask;
|
m_nsWindow.styleMask |= NSResizableWindowMask;
|
||||||
else
|
else
|
||||||
m_nsWindow.styleMask &= ~NSResizableWindowMask;
|
m_nsWindow.styleMask &= ~NSResizableWindowMask;
|
||||||
|
@ -1114,15 +1114,15 @@ public:
|
||||||
|
|
||||||
EWindowStyle getStyle() const
|
EWindowStyle getStyle() const
|
||||||
{
|
{
|
||||||
int retval = 0;
|
EWindowStyle retval = EWindowStyle::None;
|
||||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
|
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
|
||||||
retval |= m_nsWindow.titleVisibility == NSWindowTitleVisible ? STYLE_TITLEBAR : 0;
|
retval |= m_nsWindow.titleVisibility == NSWindowTitleVisible ? EWindowStyle::Titlebar : EWindowStyle::None;
|
||||||
#else
|
#else
|
||||||
retval |= STYLE_TITLEBAR;
|
retval |= EWindowStyle::Titlebar;
|
||||||
#endif
|
#endif
|
||||||
retval |= (m_nsWindow.styleMask & NSClosableWindowMask) ? STYLE_CLOSE : 0;
|
retval |= (m_nsWindow.styleMask & NSClosableWindowMask) ? EWindowStyle::Close : EWindowStyle::None;
|
||||||
retval |= (m_nsWindow.styleMask & NSResizableWindowMask) ? STYLE_RESIZE: 0;
|
retval |= (m_nsWindow.styleMask & NSResizableWindowMask) ? EWindowStyle::Resize: EWindowStyle::None;
|
||||||
return EWindowStyle(retval);
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void waitForRetrace()
|
void waitForRetrace()
|
||||||
|
|
|
@ -339,8 +339,8 @@ struct TestApplicationCallback : IApplicationCallback
|
||||||
pipeline = d3dF->newShaderPipeline(VS, PS, vsCompile, psCompile, cachedPipeline, vfmt,
|
pipeline = d3dF->newShaderPipeline(VS, PS, vsCompile, psCompile, cachedPipeline, vfmt,
|
||||||
BlendFactorOne, BlendFactorZero, true, true, false);
|
BlendFactorOne, BlendFactorZero, true, true, false);
|
||||||
}
|
}
|
||||||
#elif __APPLE__
|
#elif BOO_HAS_METAL
|
||||||
else if (factory->platform() == IGraphicsDataFactory::PlatformMetal)
|
else if (factory->platform() == IGraphicsDataFactory::Platform::Metal)
|
||||||
{
|
{
|
||||||
MetalDataFactory* metalF = dynamic_cast<MetalDataFactory*>(factory);
|
MetalDataFactory* metalF = dynamic_cast<MetalDataFactory*>(factory);
|
||||||
|
|
||||||
|
@ -368,12 +368,10 @@ struct TestApplicationCallback : IApplicationCallback
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
pipeline = metalF->newShaderPipeline(VS, FS, vfmt, self->m_renderTarget,
|
pipeline = metalF->newShaderPipeline(VS, FS, vfmt, self->m_renderTarget,
|
||||||
BlendFactorOne, BlendFactorZero, true, true, false);
|
BlendFactor::One, BlendFactor::Zero, true, true, false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Make shader data binding */
|
/* Make shader data binding */
|
||||||
self->m_binding =
|
self->m_binding =
|
||||||
factory->newShaderDataBinding(pipeline, vfmt, vbo, nullptr, 0, nullptr, 1, &texture);
|
factory->newShaderDataBinding(pipeline, vfmt, vbo, nullptr, 0, nullptr, 1, &texture);
|
||||||
|
@ -387,7 +385,6 @@ struct TestApplicationCallback : IApplicationCallback
|
||||||
|
|
||||||
/* Wait for exit */
|
/* Wait for exit */
|
||||||
while (self->running)
|
while (self->running)
|
||||||
{
|
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lk(self->m_mt);
|
std::unique_lock<std::mutex> lk(self->m_mt);
|
||||||
self->m_cv.wait(lk);
|
self->m_cv.wait(lk);
|
||||||
|
@ -395,7 +392,6 @@ struct TestApplicationCallback : IApplicationCallback
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int appMain(IApplication* app)
|
int appMain(IApplication* app)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue