From 4ba9212d35c51efccd0b44d9bce3e73a8a206534 Mon Sep 17 00:00:00 2001 From: Branimir Karadzic Date: Sat, 11 Oct 2014 22:24:07 -0700 Subject: [PATCH] Cleanup. --- src/glcontext_nsgl.mm | 53 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/src/glcontext_nsgl.mm b/src/glcontext_nsgl.mm index fa1a85885..9c5facacc 100644 --- a/src/glcontext_nsgl.mm +++ b/src/glcontext_nsgl.mm @@ -15,6 +15,26 @@ namespace bgfx # define GL_IMPORT(_optional, _proto, _func, _import) _proto _func # include "glimports.h" + + struct SwapChainGL + { + SwapChainGL(void* _nwh) + { + BX_UNUSED(_nwh); + } + + ~SwapChainGL() + { + } + + void makeCurrent() + { + } + + void swapBuffers() + { + } + }; static void* s_opengl = NULL; @@ -94,27 +114,40 @@ namespace bgfx return false; } - SwapChainGL* GlContext::createSwapChain(void* /*_nwh*/) + SwapChainGL* GlContext::createSwapChain(void* _nwh) { - BX_CHECK(false, "Shouldn't be called!"); - return NULL; + return BX_NEW(g_allocator, SwapChainGL)(_nwh); } - void GlContext::destorySwapChain(SwapChainGL* /*_swapChain*/) + void GlContext::destorySwapChain(SwapChainGL* _swapChain) { - BX_CHECK(false, "Shouldn't be called!"); + BX_DELETE(g_allocator, _swapChain); } void GlContext::swap(SwapChainGL* _swapChain) { - BX_CHECK(NULL == _swapChain, "Shouldn't be called!"); BX_UNUSED(_swapChain); - NSOpenGLContext* glContext = (NSOpenGLContext*)m_context; - [glContext makeCurrentContext]; - [glContext flushBuffer]; + if (NULL == _swapChain) + { + NSOpenGLContext* glContext = (NSOpenGLContext*)m_context; + [glContext makeCurrentContext]; + [glContext flushBuffer]; + } + else + { + _swapChain->makeCurrent(); + _swapChain->swapBuffers(); + } } - void GlContext::makeCurrent(SwapChainGL* /*_swapChain*/) + void GlContext::makeCurrent(SwapChainGL* _swapChain) { + if (NULL == _swapChain) + { + } + else + { + _swapChain->makeCurrent(); + } } void GlContext::import()