diff --git a/src/gl_context.c b/src/gl_context.c index 8a6982342..a1dabb6ef 100644 --- a/src/gl_context.c +++ b/src/gl_context.c @@ -57,6 +57,10 @@ #include "debug.h" #include "gl_context.h" +#if defined HAVE_GL && !defined HAVE_MACOSX +# include +#endif + /** * @brief initializes specified OpenGL context * @@ -226,4 +230,18 @@ void gl_context_make_current(struct gl_context *context) #endif } +void uvGlutInit(int *argcp, char **argv) +{ +#ifdef HAVE_GL +# ifdef HAVE_MACOSX + macGlutInit(argcp, argv); +# else + glutInit(argcp, argv); +# endif +#else + UNUSED(argcp); + UNUSED(argv); +#endif +} + #endif /* defined HAVE_MACOSX || (defined HAVE_LINUX && defined HAVE_LIBGLEW) */ diff --git a/src/gl_context.h b/src/gl_context.h index 3f7bf64c1..08bd43d19 100644 --- a/src/gl_context.h +++ b/src/gl_context.h @@ -127,6 +127,7 @@ static void gl_check_error() GLuint glsl_compile_link(const char *vprogram, const char *fprogram); +void uvGlutInit(int *argcp, char **argv); #ifdef __cplusplus } diff --git a/src/host.cpp b/src/host.cpp index 0dd45d3ee..d087f6692 100644 --- a/src/host.cpp +++ b/src/host.cpp @@ -77,6 +77,10 @@ #define X11_LIB_NAME "libX11.so.6" #endif +#if defined HAVE_GL && defined HAVE_MACOSX +#include +#endif + #ifdef USE_MTRACE #include #endif @@ -216,6 +220,10 @@ struct init_data *common_preinit(int argc, char *argv[]) } #endif +#if defined HAVE_GL && defined HAVE_MACOSX + glutInit(&uv_argc, uv_argv); +#endif + #ifdef WIN32 WSADATA wsaData; int err = WSAStartup(MAKEWORD(2, 2), &wsaData); diff --git a/src/mac_gl_common.h b/src/mac_gl_common.h index eaf9bff15..12370d03e 100644 --- a/src/mac_gl_common.h +++ b/src/mac_gl_common.h @@ -43,4 +43,5 @@ int get_mac_kernel_version_major(); void *mac_gl_init(mac_opengl_version_t); void mac_gl_free(void *); void mac_gl_make_current(void *); +void macGlutInit(int *argcp, char **argv); diff --git a/src/mac_gl_common.m b/src/mac_gl_common.m index 870fd0d4f..27a18dceb 100644 --- a/src/mac_gl_common.m +++ b/src/mac_gl_common.m @@ -58,7 +58,7 @@ #include #include #include - +#include #ifndef __MAC_10_11 #warning "You are compling on pre-10.7 Mac OS X version. Core OpenGL 3.2 profile won't work" @@ -207,3 +207,10 @@ void mac_gl_make_current(void * state) } @end +void macGlutInit(int *argcp, char **argv) +{ + if (NSApp == nil) { + glutInit(argcp, argv); + } +} + diff --git a/src/video_capture/syphon.mm b/src/video_capture/syphon.mm index 67d44d651..a840f0180 100644 --- a/src/video_capture/syphon.mm +++ b/src/video_capture/syphon.mm @@ -328,7 +328,7 @@ static void syphon_mainloop(void *state) state_global = (struct state_vidcap_syphon *) state; struct state_vidcap_syphon *s = state_global; - glutInit(&uv_argc, uv_argv); + uvGlutInit(&uv_argc, uv_argv); glutInitDisplayMode(GLUT_RGB); s->window = glutCreateWindow("dummy Syphon client window"); glutHideWindow(); diff --git a/src/video_display/gl.cpp b/src/video_display/gl.cpp index b2921dd4d..4d62ea0eb 100644 --- a/src/video_display/gl.cpp +++ b/src/video_display/gl.cpp @@ -1160,7 +1160,7 @@ static bool display_gl_init_opengl(struct state_gl *s) glutInitErrorFunc(glut_init_error_callback); if (setjmp(error_env) == 0) { #endif - glutInit(&uv_argc, uv_argv); + uvGlutInit(&uv_argc, uv_argv); #ifdef FREEGLUT } else { exit_uv(EXIT_FAIL_DISPLAY);