CocoaWindow bug fix

This commit is contained in:
Jack Andersen 2016-01-15 20:11:25 -10:00
parent 5fe0d34a43
commit ca105fcde6
1 changed files with 14 additions and 12 deletions

View File

@ -37,6 +37,7 @@ static const NSOpenGLPixelFormatAttribute PF_RGBA8_ATTRS[] =
NSOpenGLPFADoubleBuffer, NSOpenGLPFADoubleBuffer,
NSOpenGLPFAColorSize, 24, NSOpenGLPFAColorSize, 24,
NSOpenGLPFAAlphaSize, 8, NSOpenGLPFAAlphaSize, 8,
0, 0
}; };
static const NSOpenGLPixelFormatAttribute PF_RGBA8_Z24_ATTRS[] = static const NSOpenGLPixelFormatAttribute PF_RGBA8_Z24_ATTRS[] =
@ -47,6 +48,7 @@ static const NSOpenGLPixelFormatAttribute PF_RGBA8_Z24_ATTRS[] =
NSOpenGLPFAColorSize, 24, NSOpenGLPFAColorSize, 24,
NSOpenGLPFAAlphaSize, 8, NSOpenGLPFAAlphaSize, 8,
NSOpenGLPFADepthSize, 24, NSOpenGLPFADepthSize, 24,
0, 0
}; };
static const NSOpenGLPixelFormatAttribute PF_RGBAF32_ATTRS[] = static const NSOpenGLPixelFormatAttribute PF_RGBAF32_ATTRS[] =
@ -57,6 +59,7 @@ static const NSOpenGLPixelFormatAttribute PF_RGBAF32_ATTRS[] =
NSOpenGLPFAColorFloat, NSOpenGLPFAColorFloat,
NSOpenGLPFAColorSize, 96, NSOpenGLPFAColorSize, 96,
NSOpenGLPFAAlphaSize, 32, NSOpenGLPFAAlphaSize, 32,
0, 0
}; };
static const NSOpenGLPixelFormatAttribute PF_RGBAF32_Z24_ATTRS[] = static const NSOpenGLPixelFormatAttribute PF_RGBAF32_Z24_ATTRS[] =
@ -68,6 +71,7 @@ static const NSOpenGLPixelFormatAttribute PF_RGBAF32_Z24_ATTRS[] =
NSOpenGLPFAColorSize, 96, NSOpenGLPFAColorSize, 96,
NSOpenGLPFAAlphaSize, 32, NSOpenGLPFAAlphaSize, 32,
NSOpenGLPFADepthSize, 24, NSOpenGLPFADepthSize, 24,
0, 0
}; };
static const NSOpenGLPixelFormatAttribute* PF_TABLE[] = static const NSOpenGLPixelFormatAttribute* PF_TABLE[] =
@ -1228,6 +1232,8 @@ public:
WindowCocoa(const std::string& title, NSOpenGLContext* lastGLCtx, MetalContext* metalCtx) WindowCocoa(const std::string& title, NSOpenGLContext* lastGLCtx, MetalContext* metalCtx)
{ {
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 BOO_HAS_METAL
if (metalCtx->m_dev) if (metalCtx->m_dev)
@ -1236,6 +1242,7 @@ public:
#endif #endif
m_gfxCtx = static_cast<GraphicsContextCocoa*>(_GraphicsContextCocoaGLNew(IGraphicsContext::EGraphicsAPI::OpenGL3_3, this, lastGLCtx)); m_gfxCtx = static_cast<GraphicsContextCocoa*>(_GraphicsContextCocoaGLNew(IGraphicsContext::EGraphicsAPI::OpenGL3_3, this, lastGLCtx));
m_gfxCtx->initializeContext(); m_gfxCtx->initializeContext();
});
} }
void _clearWindow() void _clearWindow()
@ -1491,12 +1498,7 @@ public:
IWindow* _WindowCocoaNew(const SystemString& title, NSOpenGLContext* lastGLCtx, MetalContext* metalCtx) IWindow* _WindowCocoaNew(const SystemString& title, NSOpenGLContext* lastGLCtx, MetalContext* metalCtx)
{ {
__block IWindow* window = nullptr; return new WindowCocoa(title, lastGLCtx, metalCtx);
dispatch_sync(dispatch_get_main_queue(),
^{
window = new WindowCocoa(title, lastGLCtx, metalCtx);
});
return window;
} }
} }