diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m
index cb4437ee34..f55392b1d6 100644
--- a/gfx/drivers_context/cocoa_gl_ctx.m
+++ b/gfx/drivers_context/cocoa_gl_ctx.m
@@ -14,38 +14,6 @@
* If not, see .
*/
-#ifdef HAVE_CONFIG_H
-#include "../../config.h"
-#endif
-
-#if TARGET_OS_IPHONE
-#include
-#else
-#include
-#endif
-#if defined(HAVE_COCOA)
-#include
-#include
-#include
-#include
-#elif defined(HAVE_COCOATOUCH)
-#include
-#endif
-
-#include
-#include
-
-#include "../../ui/drivers/ui_cocoa.h"
-#include "../../ui/drivers/cocoa/cocoa_common.h"
-#include "../video_driver.h"
-#include "../../configuration.h"
-#include "../../verbosity.h"
-
-typedef struct cocoa_ctx_data
-{
- bool core_hw_context_enable;
-} cocoa_ctx_data_t;
-
#include "cocoa_gl_shared.h"
static void *cocoagl_gfx_ctx_init(video_frame_info_t *video_info, void *video_driver)
diff --git a/gfx/drivers_context/cocoa_gl_ctx_metal.m b/gfx/drivers_context/cocoa_gl_ctx_metal.m
index 02e65a026d..2952cf401b 100644
--- a/gfx/drivers_context/cocoa_gl_ctx_metal.m
+++ b/gfx/drivers_context/cocoa_gl_ctx_metal.m
@@ -13,47 +13,6 @@
* If not, see .
*/
-#ifdef HAVE_CONFIG_H
-#include "../../config.h"
-#endif
-
-#if TARGET_OS_IPHONE
-#include
-#else
-#include
-#endif
-#if defined(HAVE_COCOA_METAL)
-#include
-#include
-#include
-#include
-#elif defined(HAVE_COCOATOUCH)
-#include
-#endif
-
-#include
-#include
-
-#include "../../ui/drivers/ui_cocoa.h"
-#include "../../ui/drivers/cocoa/cocoa_common.h"
-#include "../video_driver.h"
-#include "../../configuration.h"
-#include "../../verbosity.h"
-#ifdef HAVE_VULKAN
-#include "../common/vulkan_common.h"
-#endif
-
-typedef struct cocoa_ctx_data
-{
- bool core_hw_context_enable;
-#ifdef HAVE_VULKAN
- gfx_ctx_vulkan_data_t vk;
- int swap_interval;
-#endif
- unsigned width;
- unsigned height;
-} cocoa_ctx_data_t;
-
#include "cocoa_gl_shared.h"
static void *cocoagl_gfx_ctx_init(video_frame_info_t *video_info, void *video_driver)
diff --git a/gfx/drivers_context/cocoa_gl_shared.h b/gfx/drivers_context/cocoa_gl_shared.h
index f9a88940e0..ee156d2dff 100644
--- a/gfx/drivers_context/cocoa_gl_shared.h
+++ b/gfx/drivers_context/cocoa_gl_shared.h
@@ -1,3 +1,62 @@
+#ifdef HAVE_CONFIG_H
+#include "../../config.h"
+#endif
+
+#if TARGET_OS_IPHONE
+#include
+#else
+#include
+#endif
+#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
+#include
+#include
+#include
+#include
+#elif defined(HAVE_COCOATOUCH)
+#include
+#endif
+
+#include
+#include
+
+#include "../../ui/drivers/ui_cocoa.h"
+#include "../../ui/drivers/cocoa/cocoa_common.h"
+#include "../video_driver.h"
+#include "../../configuration.h"
+#include "../../verbosity.h"
+#ifdef HAVE_VULKAN
+#include "../common/vulkan_common.h"
+#endif
+
+typedef struct cocoa_ctx_data
+{
+ bool core_hw_context_enable;
+#ifdef HAVE_VULKAN
+ gfx_ctx_vulkan_data_t vk;
+ int swap_interval;
+#endif
+ unsigned width;
+ unsigned height;
+} cocoa_ctx_data_t;
+
+#if defined(HAVE_COCOATOUCH)
+#define GLContextClass EAGLContext
+#define GLFrameworkID CFSTR("com.apple.opengles")
+#define RAScreen UIScreen
+
+#ifndef UIUserInterfaceIdiomTV
+#define UIUserInterfaceIdiomTV 2
+#endif
+
+#ifndef UIUserInterfaceIdiomCarPlay
+#define UIUserInterfaceIdiomCarPlay 3
+#endif
+#else
+#define GLContextClass NSOpenGLContext
+#define GLFrameworkID CFSTR("com.apple.opengl")
+#define RAScreen NSScreen
+#endif
+
static enum gfx_ctx_api cocoagl_api = GFX_CTX_NONE;
#if defined(HAVE_COCOATOUCH)
@@ -16,27 +75,12 @@ static unsigned g_minor = 0;
static unsigned g_major = 0;
#if defined(HAVE_COCOATOUCH)
-#define GLContextClass EAGLContext
-#define GLFrameworkID CFSTR("com.apple.opengles")
-#define RAScreen UIScreen
-
-#ifndef UIUserInterfaceIdiomTV
-#define UIUserInterfaceIdiomTV 2
-#endif
-
-#ifndef UIUserInterfaceIdiomCarPlay
-#define UIUserInterfaceIdiomCarPlay 3
-#endif
-
-
@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
@@ -46,10 +90,6 @@ static unsigned g_major = 0;
}
- (float) scale { return 1.0f; }
@end
-
-#define GLContextClass NSOpenGLContext
-#define GLFrameworkID CFSTR("com.apple.opengl")
-#define RAScreen NSScreen
#endif
/* forward declaration */