From 1bf5f4f3da8e18df54f368cb6e25f083ce3fcc36 Mon Sep 17 00:00:00 2001 From: Struma Date: Mon, 10 Feb 2020 12:38:27 -0500 Subject: [PATCH] Make threaded GL initialization optional --- meson.build | 7 ++++++- meson_options.txt | 4 ++-- src/main.mm | 8 ++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index 1a735c9b..138db765 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ -project('mkxp-z', 'cpp', 'objc', 'objcpp', version: '1.2.0', meson_version: '>=0.47.0', default_options: ['cpp_std=c++11', 'buildtype=release']) +project('mkxp-z', 'cpp', 'objc', 'objcpp', version: '1.2.0', meson_version: '>=0.47.0', default_options: ['cpp_std=c++11', 'objcpp_std=c++11','buildtype=release']) minimum_macos_version = get_option('macos_min_version') @@ -84,6 +84,11 @@ if get_option('mk') global_args += '-DMARIN' endif +# This MUST be disabled if building for macOS >= 10.15 +if get_option('threaded_gl_init') + global_args += '-DTHREADED_GLINIT' +endif + # Objectify our C global_args += run_command(objfw,'--cppflags').stdout().split() diff --git a/meson_options.txt b/meson_options.txt index e971a1fd..e0abc6bd 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,8 +1,8 @@ option('mri_version', type: 'string', value: '1.8', description: 'Version of MRI to link with') option('mk', type: 'boolean', value: false, description: 'Build to fit Marin\'s MK standard') -option('ruby_lib', type: 'string', value: 'ruby', description: 'Name of the Ruby library') option('console', type: 'boolean', value: true, description: 'Whether to debug information in the console') option('macos_min_version', type: 'string', value: '10.10', description: 'Minimum macOS system version to support') +option('threaded_gl_init', type: 'boolean', value: true, description: 'Init GL on secondary thread') option('shared_fluid', type: 'boolean', value: false, description: 'Dynamically link fluidsynth at build time') option('cjk_fallback_font', type: 'boolean', value: false, description: 'Use WenQuanYi Micro Hei as the fallback font') @@ -14,4 +14,4 @@ option('workdir_current', type: 'boolean', value: false, description: 'Keep curr option('independent_appimage', type: 'boolean', value: true, description: 'Set current directory to the original location of the AppImage when contained within one') option('discord_sdk_path', type: 'string', value: '', description: 'Path to Discord GameSDK') -option('appimagekit_path', type: 'string', value: '', description: 'Path to AppImageKit, used for building AppImages') \ No newline at end of file +option('appimagekit_path', type: 'string', value: '', description: 'Path to AppImageKit, used for building AppImages') diff --git a/src/main.mm b/src/main.mm index eb44e83b..9677bf5f 100644 --- a/src/main.mm +++ b/src/main.mm @@ -49,7 +49,7 @@ #import "icon.png.xxd" -#ifdef __APPLE__ +#ifndef THREADED_GLINIT #define GLINIT_SHOWERROR(s) showInitError(s) #else #define GLINIT_SHOWERROR(s) rgssThreadError(threadData, s) @@ -75,7 +75,7 @@ static SDL_GLContext initGL(SDL_Window *win, Config &conf, int rgssThreadFun(void *userdata) { RGSSThreadData *threadData = static_cast(userdata); -#ifndef __APPLE__ +#ifdef THREADED_GLINIT threadData->glContext = initGL(threadData->window, threadData->config, threadData); if (!threadData->glContext) @@ -322,7 +322,7 @@ int main(int argc, char *argv[]) { EventThread eventThread; -#ifdef __APPLE__ +#ifndef THREADED_GLINIT SDL_GLContext glCtx = initGL(win, conf, 0); #else SDL_GLContext glCtx = NULL; @@ -439,4 +439,4 @@ static SDL_GLContext initGL(SDL_Window *win, Config &conf, // GLDebugLogger dLogger; return glCtx; -} \ No newline at end of file +}