cocoa: move the gl function loader to gl_cocoa.c

This commit is contained in:
Stefano Pigozzi 2014-12-28 19:10:44 +01:00
parent 9270dda50a
commit f987625d5a
3 changed files with 15 additions and 17 deletions

View File

@ -24,8 +24,6 @@
struct vo_cocoa_state;
void *vo_cocoa_glgetaddr(const char *s);
int vo_cocoa_init(struct vo *vo);
void vo_cocoa_uninit(struct vo *vo);

View File

@ -20,7 +20,6 @@
#import <Cocoa/Cocoa.h>
#import <CoreServices/CoreServices.h> // for CGDisplayHideCursor
#import <IOKit/pwr_mgt/IOPMLib.h>
#include <dlfcn.h>
#import "cocoa_common.h"
#import "video/out/cocoa/window.h"
@ -112,19 +111,6 @@ static void queue_new_video_size(struct vo *vo, int w, int h)
}
}
void *vo_cocoa_glgetaddr(const char *s)
{
void *ret = NULL;
void *handle = dlopen(
"/System/Library/Frameworks/OpenGL.framework/OpenGL",
RTLD_LAZY | RTLD_LOCAL);
if (!handle)
return NULL;
ret = dlsym(handle, s);
dlclose(handle);
return ret;
}
static void enable_power_management(struct vo *vo)
{
struct vo_cocoa_state *s = vo->cocoa;

View File

@ -20,6 +20,7 @@
*/
#include <OpenGL/OpenGL.h>
#include <dlfcn.h>
#include "cocoa_common.h"
#include "osdep/macosx_versions.h"
#include "gl_common.h"
@ -44,6 +45,19 @@ static int cgl_color_size(struct MPGLContext *ctx)
return value > 16 ? 8 : 5;
}
static void *cocoa_glgetaddr(const char *s)
{
void *ret = NULL;
void *handle = dlopen(
"/System/Library/Frameworks/OpenGL.framework/OpenGL",
RTLD_LAZY | RTLD_LOCAL);
if (!handle)
return NULL;
ret = dlsym(handle, s);
dlclose(handle);
return ret;
}
static bool create_gl_context(struct MPGLContext *ctx)
{
struct cgl_context *p = ctx->priv;
@ -102,7 +116,7 @@ static bool create_gl_context(struct MPGLContext *ctx)
vo_cocoa_create_nsgl_ctx(ctx->vo, p->ctx);
ctx->depth_r = ctx->depth_g = ctx->depth_b = cgl_color_size(ctx);
mpgl_load_functions(ctx->gl, (void *)vo_cocoa_glgetaddr, NULL, ctx->vo->log);
mpgl_load_functions(ctx->gl, (void *)cocoa_glgetaddr, NULL, ctx->vo->log);
CGLReleasePixelFormat(p->pix);