(Cocoa GL) Global variable cleanups
This commit is contained in:
parent
6c7143d02d
commit
ca2a59e03d
|
@ -52,28 +52,25 @@
|
||||||
|
|
||||||
typedef struct cocoa_ctx_data
|
typedef struct cocoa_ctx_data
|
||||||
{
|
{
|
||||||
|
bool is_syncing;
|
||||||
bool core_hw_context_enable;
|
bool core_hw_context_enable;
|
||||||
|
bool use_hw_ctx;
|
||||||
#ifdef HAVE_VULKAN
|
#ifdef HAVE_VULKAN
|
||||||
gfx_ctx_vulkan_data_t vk;
|
gfx_ctx_vulkan_data_t vk;
|
||||||
int swap_interval;
|
int swap_interval;
|
||||||
#endif
|
#endif
|
||||||
|
int fast_forward_skips;
|
||||||
unsigned width;
|
unsigned width;
|
||||||
unsigned height;
|
unsigned height;
|
||||||
} cocoa_ctx_data_t;
|
} cocoa_ctx_data_t;
|
||||||
|
|
||||||
static enum gfx_ctx_api cocoagl_api = GFX_CTX_NONE;
|
/* TODO/FIXME - static globals */
|
||||||
|
|
||||||
#if defined(HAVE_COCOATOUCH)
|
#if defined(HAVE_COCOATOUCH)
|
||||||
static GLKView *g_view;
|
static GLKView *g_view = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
static enum gfx_ctx_api cocoagl_api = GFX_CTX_NONE;
|
||||||
static GLContextClass* g_hw_ctx;
|
static GLContextClass* g_hw_ctx = NULL;
|
||||||
static GLContextClass* g_context;
|
static GLContextClass* g_context = NULL;
|
||||||
|
|
||||||
static int g_fast_forward_skips;
|
|
||||||
static bool g_is_syncing = true;
|
|
||||||
static bool g_use_hw_ctx = false;
|
|
||||||
|
|
||||||
static unsigned g_minor = 0;
|
static unsigned g_minor = 0;
|
||||||
static unsigned g_major = 0;
|
static unsigned g_major = 0;
|
||||||
|
|
||||||
|
@ -527,12 +524,13 @@ static gfx_ctx_proc_t cocoagl_gfx_ctx_get_proc_address(const char *symbol_name)
|
||||||
|
|
||||||
static void cocoagl_gfx_ctx_bind_hw_render(void *data, bool enable)
|
static void cocoagl_gfx_ctx_bind_hw_render(void *data, bool enable)
|
||||||
{
|
{
|
||||||
(void)data;
|
cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data;
|
||||||
|
|
||||||
switch (cocoagl_api)
|
switch (cocoagl_api)
|
||||||
{
|
{
|
||||||
case GFX_CTX_OPENGL_API:
|
case GFX_CTX_OPENGL_API:
|
||||||
case GFX_CTX_OPENGL_ES_API:
|
case GFX_CTX_OPENGL_ES_API:
|
||||||
g_use_hw_ctx = enable;
|
cocoa_ctx->use_hw_ctx = enable;
|
||||||
|
|
||||||
if (enable)
|
if (enable)
|
||||||
[g_hw_ctx makeCurrentContext];
|
[g_hw_ctx makeCurrentContext];
|
||||||
|
@ -593,8 +591,8 @@ static void cocoagl_gfx_ctx_swap_interval(void *data, int i)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_COCOATOUCH) // < No way to disable Vsync on iOS?
|
#if defined(HAVE_COCOATOUCH) // < No way to disable Vsync on iOS?
|
||||||
// Just skip presents so fast forward still works.
|
// Just skip presents so fast forward still works.
|
||||||
g_is_syncing = interval ? true : false;
|
cocoa_ctx->is_syncing = interval ? true : false;
|
||||||
g_fast_forward_skips = interval ? 0 : 3;
|
cocoa_ctx->fast_forward_skips = interval ? 0 : 3;
|
||||||
#elif defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
|
#elif defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
|
||||||
GLint value = interval ? 1 : 0;
|
GLint value = interval ? 1 : 0;
|
||||||
[g_context setValues:&value forParameter:NSOpenGLCPSwapInterval];
|
[g_context setValues:&value forParameter:NSOpenGLCPSwapInterval];
|
||||||
|
@ -627,7 +625,7 @@ static void cocoagl_gfx_ctx_swap_buffers(void *data)
|
||||||
{
|
{
|
||||||
case GFX_CTX_OPENGL_API:
|
case GFX_CTX_OPENGL_API:
|
||||||
case GFX_CTX_OPENGL_ES_API:
|
case GFX_CTX_OPENGL_ES_API:
|
||||||
if (!(--g_fast_forward_skips < 0))
|
if (!(--cocoa_ctx->fast_forward_skips < 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if TARGET_OS_OSX
|
#if TARGET_OS_OSX
|
||||||
|
@ -638,7 +636,7 @@ static void cocoagl_gfx_ctx_swap_buffers(void *data)
|
||||||
[g_view display];
|
[g_view display];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_fast_forward_skips = g_is_syncing ? 0 : 3;
|
cocoa_ctx->fast_forward_skips = cocoa_ctx->is_syncing ? 0 : 3;
|
||||||
break;
|
break;
|
||||||
case GFX_CTX_VULKAN_API:
|
case GFX_CTX_VULKAN_API:
|
||||||
#ifdef HAVE_VULKAN
|
#ifdef HAVE_VULKAN
|
||||||
|
@ -759,12 +757,12 @@ static bool cocoagl_gfx_ctx_set_video_mode(void *data,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (g_use_hw_ctx)
|
if (cocoa_ctx->use_hw_ctx)
|
||||||
g_hw_ctx = [[NSOpenGLContext alloc] initWithFormat:g_format shareContext:nil];
|
g_hw_ctx = [[NSOpenGLContext alloc] initWithFormat:g_format shareContext:nil];
|
||||||
g_context = [[NSOpenGLContext alloc] initWithFormat:g_format shareContext:(g_use_hw_ctx) ? g_hw_ctx : nil];
|
g_context = [[NSOpenGLContext alloc] initWithFormat:g_format shareContext:(cocoa_ctx->use_hw_ctx) ? g_hw_ctx : nil];
|
||||||
[g_context setView:g_view];
|
[g_context setView:g_view];
|
||||||
#else
|
#else
|
||||||
if (g_use_hw_ctx)
|
if (cocoa_ctx->use_hw_ctx)
|
||||||
g_hw_ctx = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
g_hw_ctx = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
||||||
g_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
g_context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
||||||
g_view.context = g_context;
|
g_view.context = g_context;
|
||||||
|
@ -835,6 +833,8 @@ static void *cocoagl_gfx_ctx_init(void *video_driver)
|
||||||
if (!cocoa_ctx)
|
if (!cocoa_ctx)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
cocoa_ctx->is_syncing = true;
|
||||||
|
|
||||||
switch (cocoagl_api)
|
switch (cocoagl_api)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_COCOATOUCH)
|
#if defined(HAVE_COCOATOUCH)
|
||||||
|
|
Loading…
Reference in New Issue