This commit is contained in:
bkaradzic 2013-07-21 15:38:44 -07:00
parent 9852949a38
commit 41dfddf424
5 changed files with 16 additions and 30 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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;
}

View File

@ -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;

View File

@ -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) );