From 53d2c8164b3fa21dbee24144ecf2bc3c09cb0703 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Fri, 3 Oct 2014 21:47:46 +0200 Subject: [PATCH] (Apple) Make apple_gfx_context.c.inl more self-contained --- apple/common/RAGameView.m | 14 +++++--------- apple/common/apple_gfx_context.c.inl | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/apple/common/RAGameView.m b/apple/common/RAGameView.m index 582f4d917d..6ac5de0300 100644 --- a/apple/common/RAGameView.m +++ b/apple/common/RAGameView.m @@ -31,17 +31,12 @@ #include #endif -#define GLContextClass EAGLContext - #elif defined(OSX) -#define GLContextClass NSOpenGLContext - /* RAGameView is a container on iOS; * on OSX these are both the same object */ #define g_view g_instance - #endif #ifdef IOS @@ -54,7 +49,6 @@ static UIView *g_pause_indicator_view; #endif static RAGameView* g_instance; -static GLContextClass* g_context; @implementation RAGameView + (RAGameView*)get @@ -91,17 +85,19 @@ static GLContextClass* g_context; #ifdef OSX +static void apple_gfx_ctx_update(void); +static void apple_gfx_ctx_flush_buffer(void); + - (void)setFrame:(NSRect)frameRect { [super setFrame:frameRect]; - if (g_context) - [g_context update]; + apple_gfx_ctx_update(); } - (void)display { - [g_context flushBuffer]; + apple_gfx_ctx_flush_buffer(); } /* Stop the annoying sound when pressing a key. */ diff --git a/apple/common/apple_gfx_context.c.inl b/apple/common/apple_gfx_context.c.inl index 3c01419247..a564337bcd 100644 --- a/apple/common/apple_gfx_context.c.inl +++ b/apple/common/apple_gfx_context.c.inl @@ -3,6 +3,7 @@ #include "../../gfx/gl_common.h" #ifdef IOS +#define GLContextClass EAGLContext #define GLFrameworkID CFSTR("com.apple.opengles") #define RAScreen UIScreen @@ -14,6 +15,7 @@ #else + @interface NSScreen (IOSCompat) @end @implementation NSScreen (IOSCompat) - (CGRect)bounds @@ -24,11 +26,13 @@ - (float) scale { return 1.0f; } @end +#define GLContextClass NSOpenGLContext #define GLFrameworkID CFSTR("com.apple.opengl") #define RAScreen NSScreen #endif static GLContextClass* g_hw_ctx; +static GLContextClass* g_context; static int g_fast_forward_skips; static bool g_is_syncing = true; @@ -65,6 +69,18 @@ static RAScreen* get_chosen_screen(void) #endif } +static void apple_gfx_ctx_update(void) +{ + if (g_context) + [g_context update]; +} + +static void apple_gfx_ctx_flush_buffer(void) +{ + if (g_context) + [g_context flushBuffer]; +} + static bool apple_gfx_ctx_init(void *data) { (void)data;