From 41dfddf4240d277bc18973c4b2f133d294b5f5dc Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Sun, 21 Jul 2013 15:38:44 -0700 Subject: [PATCH] Cleanup. --- examples/common/entry_ios.mm | 23 +---------------------- include/bgfxplatform.h | 2 +- src/bgfx.cpp | 4 +--- src/bgfx_p.h | 1 - src/glcontext_eagl.mm | 16 +++++++++++++--- 5 files changed, 16 insertions(+), 30 deletions(-) diff --git a/examples/common/entry_ios.mm b/examples/common/entry_ios.mm index 542017dfe..da055d8ea 100644 --- a/examples/common/entry_ios.mm +++ b/examples/common/entry_ios.mm @@ -96,19 +96,13 @@ using namespace entry; @interface EAGLView : UIView { - - EAGLContext* m_context; CADisplayLink* m_displayLink; } -@property (nonatomic, retain) EAGLContext* m_context; - @end @implementation EAGLView -@synthesize m_context; - + (Class)layerClass { return [CAEAGLLayer class]; @@ -124,22 +118,7 @@ using namespace entry; } CAEAGLLayer* layer = (CAEAGLLayer*)self.layer; - layer.opaque = true; - - layer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys - : [NSNumber numberWithBool:false] - , kEAGLDrawablePropertyRetainedBacking - , kEAGLColorFormatRGBA8 - , kEAGLDrawablePropertyColorFormat - , nil - ]; - - m_context = [ [EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; - BX_CHECK(NULL != m_context, "Failed to create kEAGLRenderingAPIOpenGLES2 context."); - - [EAGLContext setCurrentContext:m_context]; - - bgfx::iosSetEaglContext(m_context, layer); + bgfx::iosSetEaglLayer(layer); return self; } diff --git a/include/bgfxplatform.h b/include/bgfxplatform.h index 28f337c50..3ac8567c4 100755 --- a/include/bgfxplatform.h +++ b/include/bgfxplatform.h @@ -23,7 +23,7 @@ namespace bgfx #elif BX_PLATFORM_IOS namespace bgfx { - void iosSetEaglContext(void* _context, void* _layer); + void iosSetEaglLayer(void* _layer); } // namespace bgfx #elif BX_PLATFORM_LINUX diff --git a/src/bgfx.cpp b/src/bgfx.cpp index e303e5f94..5969c045c 100755 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -40,11 +40,9 @@ namespace bgfx g_bgfxAndroidWindow = _window; } #elif BX_PLATFORM_IOS - void* g_bgfxEaglContext = NULL; void* g_bgfxEaglLayer = NULL; - void iosSetEaglContext(void* _context, void* _layer) + void iosSetEaglLayer(void* _layer) { - g_bgfxEaglContext = _context; g_bgfxEaglLayer = _layer; } diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 8d336edf0..f6a1129c3 100755 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -157,7 +157,6 @@ namespace bgfx #if BX_PLATFORM_ANDROID extern ::ANativeWindow* g_bgfxAndroidWindow; #elif BX_PLATFORM_IOS - extern void* g_bgfxEaglContext; extern void* g_bgfxEaglLayer; #elif BX_PLATFORM_OSX extern void* g_bgfxNSWindow; diff --git a/src/glcontext_eagl.mm b/src/glcontext_eagl.mm index 9b9d10d80..f0a48f470 100644 --- a/src/glcontext_eagl.mm +++ b/src/glcontext_eagl.mm @@ -14,11 +14,21 @@ namespace bgfx { void GlContext::create(uint32_t _width, uint32_t _height) { - EAGLContext* context = (EAGLContext*)g_bgfxEaglContext; CAEAGLLayer* layer = (CAEAGLLayer*)g_bgfxEaglLayer; - [EAGLContext setCurrentContext:context]; + layer.opaque = true; - m_context = g_bgfxEaglContext; + layer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys + : [NSNumber numberWithBool:false] + , kEAGLDrawablePropertyRetainedBacking + , kEAGLColorFormatRGBA8 + , kEAGLDrawablePropertyColorFormat + , nil + ]; + + EAGLContext* context = [ [EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; + BX_CHECK(NULL != context, "Failed to create kEAGLRenderingAPIOpenGLES2 context."); + m_context = (void*)context; + [EAGLContext setCurrentContext:context]; GL_CHECK(glGenFramebuffers(1, &m_fbo) ); GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_fbo) );