diff options
author | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2011-10-15 18:44:00 +0200 |
---|---|---|
committer | Uoti Urpala <uau@mplayer2.org> | 2011-11-26 20:04:16 +0200 |
commit | 421c840b3c061de89b426244fe75237a73f765de (patch) | |
tree | 78306817be89c68a6f380078c5d278255e24f99b /libvo/gl_common.c | |
parent | 4a8ee6d9a4266589b25a817eb9fbc71a11704bc8 (diff) | |
download | mpv-421c840b3c061de89b426244fe75237a73f765de.tar.bz2 mpv-421c840b3c061de89b426244fe75237a73f765de.tar.xz |
vo_gl: add native mac osx Cocoa backend for vo_gl
Add native Cocoa code to display an OpenGL window. Some of the code is
based on the OpenGL parts of vo_corevideo but I took the time to remove
old code based on Carbon.
There is autodetection in the configure script but you can use
--enable[disable]-cocoa to enable[disable] this.
Diffstat (limited to 'libvo/gl_common.c')
-rw-r--r-- | libvo/gl_common.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/libvo/gl_common.c b/libvo/gl_common.c index 4e322ca627..d35318bd68 100644 --- a/libvo/gl_common.c +++ b/libvo/gl_common.c @@ -1610,6 +1610,46 @@ void glDrawTex(GL *gl, GLfloat x, GLfloat y, GLfloat w, GLfloat h, gl->End(); } +#ifdef CONFIG_GL_COCOA +#include "cocoa_common.h" +static int create_window_cocoa(struct MPGLContext *ctx, uint32_t d_width, + uint32_t d_height, uint32_t flags, + const char *title) +{ + return vo_cocoa_create_window(ctx, d_width, d_height, flags, title); +} +static int setGlWindow_cocoa(MPGLContext *ctx) +{ + vo_cocoa_change_attributes(ctx); + getFunctions(ctx->gl, (void *)getdladdr, NULL); + return SET_WINDOW_OK; +} + +static void releaseGlContext_cocoa(MPGLContext *ctx) +{ +} + +static void swapGlBuffers_cocoa(MPGLContext *ctx) +{ + vo_cocoa_swap_buffers(); +} + +static int cocoa_check_events(struct vo *vo) +{ + return vo_cocoa_check_events(vo); +} + +static void cocoa_update_xinerama_info(struct vo *vo) +{ + vo_cocoa_update_xinerama_info(vo); +} + +static void cocoa_fullscreen(struct vo *vo) +{ + vo_cocoa_fullscreen(vo); +} +#endif + #ifdef CONFIG_GL_WIN32 #include "w32_common.h" @@ -1982,6 +2022,9 @@ MPGLContext *init_mpglcontext(enum MPGLType type, struct vo *vo) { MPGLContext *ctx; if (type == GLTYPE_AUTO) { + ctx = init_mpglcontext(GLTYPE_COCOA, vo); + if (ctx) + return ctx; ctx = init_mpglcontext(GLTYPE_W32, vo); if (ctx) return ctx; @@ -1995,6 +2038,19 @@ MPGLContext *init_mpglcontext(enum MPGLType type, struct vo *vo) ctx->type = type; ctx->vo = vo; switch (ctx->type) { +#ifdef CONFIG_GL_COCOA + case GLTYPE_COCOA: + ctx->create_window = create_window_cocoa; + ctx->setGlWindow = setGlWindow_cocoa; + ctx->releaseGlContext = releaseGlContext_cocoa; + ctx->swapGlBuffers = swapGlBuffers_cocoa; + ctx->check_events = cocoa_check_events; + ctx->update_xinerama_info = cocoa_update_xinerama_info; + ctx->fullscreen = cocoa_fullscreen; + if (vo_cocoa_init(vo)) + return ctx; + break; +#endif #ifdef CONFIG_GL_WIN32 case GLTYPE_W32: ctx->create_window = create_window_w32; @@ -2053,6 +2109,11 @@ void uninit_mpglcontext(MPGLContext *ctx) return; ctx->releaseGlContext(ctx); switch (ctx->type) { +#ifdef CONFIG_GL_COCOA + case GLTYPE_COCOA: + vo_cocoa_uninit(ctx->vo); + break; +#endif #ifdef CONFIG_GL_WIN32 case GLTYPE_W32: vo_w32_uninit(); |