Add cocoa_gl_shared.h

This commit is contained in:
twinaphex 2019-02-10 00:31:27 +01:00
parent 8a033bbf35
commit 6f43b7974b
4 changed files with 32 additions and 50 deletions

View File

@ -35,7 +35,8 @@
#include <retro_assert.h>
#include <compat/apple_compat.h>
#import "../../ui/drivers/cocoa/cocoa_common.h"
#include "../../ui/drivers/ui_cocoa.h"
#include "../../ui/drivers/cocoa/cocoa_common.h"
#include "../video_driver.h"
#include "../../configuration.h"
#include "../../verbosity.h"
@ -97,7 +98,6 @@ static bool g_is_syncing = true;
static bool g_use_hw_ctx = false;
#if defined(HAVE_COCOA)
#include "../../ui/drivers/ui_cocoa.h"
static NSOpenGLPixelFormat* g_format;
void *glcontext_get_ptr(void)
@ -121,6 +121,8 @@ static void glkitview_init_xibs(void)
}
#endif
#include "cocoa_gl_shared.h"
void *glkitview_init(void)
{
#if defined(HAVE_COCOATOUCH)
@ -625,28 +627,6 @@ static void cocoagl_gfx_ctx_bind_hw_render(void *data, bool enable)
[g_context makeCurrentContext];
}
static uint32_t cocoagl_gfx_ctx_get_flags(void *data)
{
uint32_t flags = 0;
cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data;
BIT32_SET(flags, GFX_CTX_FLAGS_NONE);
if (cocoa_ctx->core_hw_context_enable)
BIT32_SET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT);
return flags;
}
static void cocoagl_gfx_ctx_set_flags(void *data, uint32_t flags)
{
(void)flags;
cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data;
if (BIT32_GET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT))
cocoa_ctx->core_hw_context_enable = true;
}
const gfx_ctx_driver_t gfx_ctx_cocoagl = {
cocoagl_gfx_ctx_init,
cocoagl_gfx_ctx_destroy,

View File

@ -34,7 +34,8 @@
#include <retro_assert.h>
#include <compat/apple_compat.h>
#import "../../ui/drivers/cocoa/cocoa_common.h"
#include "../../ui/drivers/ui_cocoa.h"
#include "../../ui/drivers/cocoa/cocoa_common.h"
#include "../video_driver.h"
#include "../../configuration.h"
#include "../../verbosity.h"
@ -55,6 +56,7 @@
#define UIUserInterfaceIdiomCarPlay 3
#endif
@interface EAGLContext (OSXCompat) @end
@implementation EAGLContext (OSXCompat)
+ (void)clearCurrentContext { [EAGLContext setCurrentContext:nil]; }
@ -104,8 +106,6 @@ static int g_fast_forward_skips;
static bool g_is_syncing = true;
static bool g_use_hw_ctx = false;
#include "../../ui/drivers/ui_cocoa.h"
#if defined(HAVE_COCOA_METAL)
static NSOpenGLPixelFormat* g_format;
@ -130,6 +130,8 @@ static void glkitview_init_xibs(void)
}
#endif
#include "cocoa_gl_shared.h"
void *glkitview_init(void)
{
#if defined(HAVE_COCOATOUCH)
@ -850,28 +852,6 @@ static void cocoagl_gfx_ctx_bind_hw_render(void *data, bool enable)
}
}
static uint32_t cocoagl_gfx_ctx_get_flags(void *data)
{
uint32_t flags = 0;
cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data;
BIT32_SET(flags, GFX_CTX_FLAGS_NONE);
if (cocoa_ctx->core_hw_context_enable)
BIT32_SET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT);
return flags;
}
static void cocoagl_gfx_ctx_set_flags(void *data, uint32_t flags)
{
(void)flags;
cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data;
if (BIT32_GET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT))
cocoa_ctx->core_hw_context_enable = true;
}
const gfx_ctx_driver_t gfx_ctx_cocoagl = {
.init = cocoagl_gfx_ctx_init,
.destroy = cocoagl_gfx_ctx_destroy,

View File

@ -0,0 +1,22 @@
static uint32_t cocoagl_gfx_ctx_get_flags(void *data)
{
uint32_t flags = 0;
cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data;
BIT32_SET(flags, GFX_CTX_FLAGS_NONE);
if (cocoa_ctx->core_hw_context_enable)
BIT32_SET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT);
return flags;
}
static void cocoagl_gfx_ctx_set_flags(void *data, uint32_t flags)
{
(void)flags;
cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data;
if (BIT32_GET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT))
cocoa_ctx->core_hw_context_enable = true;
}

View File

@ -499,7 +499,7 @@ static char** waiting_argv;
- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames
{
if (filenames.count == 1 && [filenames objectAtIndex:0])
if (filenames.count == 1 && filenames[0])
{
struct retro_system_info *system = runloop_get_libretro_system_info();
NSString *__core = filenames[0];