diff --git a/apple/common/RAGameView.m b/apple/common/RAGameView.m index 37c8f75298..9d0b14b875 100644 --- a/apple/common/RAGameView.m +++ b/apple/common/RAGameView.m @@ -30,33 +30,10 @@ #include #endif -#define APP_HAS_FOCUS ([[UIApplication sharedApplication] applicationState] == UIApplicationStateActive) - #define GLContextClass EAGLContext - -@interface EAGLContext (OSXCompat) @end -@implementation EAGLContext (OSXCompat) -+ (void)clearCurrentContext { [EAGLContext setCurrentContext:nil]; } -- (void)makeCurrentContext { [EAGLContext setCurrentContext:self]; } -@end - #elif defined(OSX) -#define APP_HAS_FOCUS ([NSApp isActive]) - #define GLContextClass NSOpenGLContext - #define g_view g_instance // < RAGameView is a container on iOS; on OSX these are both the same object - -@interface NSScreen (IOSCompat) @end -@implementation NSScreen (IOSCompat) -- (CGRect)bounds -{ - CGRect cgrect = NSRectToCGRect(self.frame); - return CGRectMake(0, 0, CGRectGetWidth(cgrect), CGRectGetHeight(cgrect)); -} -- (float) scale { return 1.0f; } -@end - #endif #ifdef IOS diff --git a/apple/common/apple_gfx_context.c.inl b/apple/common/apple_gfx_context.c.inl index cae9154e39..2a2691aecf 100644 --- a/apple/common/apple_gfx_context.c.inl +++ b/apple/common/apple_gfx_context.c.inl @@ -6,7 +6,25 @@ #define GLAPIType GFX_CTX_OPENGL_ES_API #define GLFrameworkID CFSTR("com.apple.opengles") #define RAScreen UIScreen + +@interface EAGLContext (OSXCompat) @end +@implementation EAGLContext (OSXCompat) ++ (void)clearCurrentContext { [EAGLContext setCurrentContext:nil]; } +- (void)makeCurrentContext { [EAGLContext setCurrentContext:self]; } +@end + #else + +@interface NSScreen (IOSCompat) @end +@implementation NSScreen (IOSCompat) +- (CGRect)bounds +{ + CGRect cgrect = NSRectToCGRect(self.frame); + return CGRectMake(0, 0, CGRectGetWidth(cgrect), CGRectGetHeight(cgrect)); +} +- (float) scale { return 1.0f; } +@end + #define GLAPIType GFX_CTX_OPENGL_API #define GLFrameworkID CFSTR("com.apple.opengl") #define RAScreen NSScreen @@ -214,7 +232,11 @@ static void apple_gfx_ctx_update_window_title(void *data) static bool apple_gfx_ctx_has_focus(void *data) { (void)data; - return APP_HAS_FOCUS; +#ifdef IOS + return ([[UIApplication sharedApplication] applicationState] == UIApplicationStateActive); +#else + return [NSApp isActive]; +#endif } static void apple_gfx_ctx_swap_buffers(void *data)