bkaradzic 12 лет назад
Родитель
Сommit
41dfddf424
5 измененных файлов с 16 добавлено и 30 удалено
  1. 1 22
      examples/common/entry_ios.mm
  2. 1 1
      include/bgfxplatform.h
  3. 1 3
      src/bgfx.cpp
  4. 0 1
      src/bgfx_p.h
  5. 13 3
      src/glcontext_eagl.mm

+ 1 - 22
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;
 }

+ 1 - 1
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

+ 1 - 3
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;
 	}
 

+ 0 - 1
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;

+ 13 - 3
src/glcontext_eagl.mm

@@ -14,12 +14,22 @@ namespace bgfx
 {
 	void GlContext::create(uint32_t _width, uint32_t _height)
 	{
-		EAGLContext* context = (EAGLContext*)g_bgfxEaglContext;
 		CAEAGLLayer* layer = (CAEAGLLayer*)g_bgfxEaglLayer;
+		layer.opaque = true;
+
+		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];
 
-		m_context = g_bgfxEaglContext;
-
 		GL_CHECK(glGenFramebuffers(1, &m_fbo) );
 		GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, m_fbo) );