From c3cd8d4fac02c5ba32cb6425006adb73ddb796be Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Tue, 4 Mar 2025 23:03:58 +0000 Subject: [PATCH] Initial port to macOS Doesn't work yet as SDL1 is broken on modern macOS. FossilOrigin-Name: f5b62f82030659a511f4add8212857fca598c6cef86a3238705eb60e35011631 --- meson.build | 7 ++++++- src/Cube.mm | 2 +- src/console.mm | 10 +++++----- src/cube.h | 14 +++++++++++--- src/editing.mm | 2 +- src/meson.build | 4 ++-- 6 files changed, 26 insertions(+), 13 deletions(-) diff --git a/meson.build b/meson.build index 204a3d7..f463127 100644 --- a/meson.build +++ b/meson.build @@ -9,7 +9,10 @@ add_global_arguments( language: 'objcpp') objfw_dep = dependency('objfw') -sdl12_dep = dependency('sdl12_compat') +sdl_dep = dependency('sdl12_compat', required: false) +if not sdl_dep.found() + sdl_dep = dependency('SDL') +endif sdlimage_dep = dependency('SDL_image') sdlmixer_dep = dependency('SDL_mixer') zlib_dep = dependency('zlib') @@ -21,6 +24,8 @@ extra_deps = [] if host_machine.system() == 'windows' client_link_args += ['-lopengl32', '-lglu32', '-lwinmm'] server_link_args += ['-lwinmm'] +elif host_machine.system() == 'darwin' + extra_deps += dependency('OpenGL', method: 'extraframework') else extra_deps += dependency('gl') extra_deps += dependency('glu') diff --git a/src/Cube.mm b/src/Cube.mm index f9e181c..574cb77 100644 --- a/src/Cube.mm +++ b/src/Cube.mm @@ -122,7 +122,7 @@ int framesinmap = 0; {'n', @"server-desc", 1, NULL, &sdesc}, {'i', @"ip", 1, NULL, &ip}, {'m', @"master", 1, NULL, &master}, {'p', @"password", 1, NULL, &passwd}, - {'c', @"max-clients", 1, NULL, NULL}}; + {'c', @"max-clients", 1, NULL, NULL}, {'\0', nil, 0, NULL, NULL}}; OFOptionsParser *optionsParser = [OFOptionsParser parserWithOptions:options]; OFUnichar option; diff --git a/src/console.mm b/src/console.mm index 7630de5..67a4210 100644 --- a/src/console.mm +++ b/src/console.mm @@ -45,10 +45,10 @@ conline(const char *sf, bool highlight) // add a line to the console buffer strcpy_s(cl.cref, sf); }; puts(cl.cref); -#ifndef _WIN32 +#ifndef OF_WINDOWS fflush(stdout); #endif -}; +} void conoutf(OFString *str, ...) @@ -144,7 +144,7 @@ mapmsg(OFString *s) } COMMAND(mapmsg, ARG_1STR) -#ifndef _WIN32 +#if !defined(OF_WINDOWS) && !defined(OF_MACOS) # include # include #endif @@ -152,7 +152,7 @@ COMMAND(mapmsg, ARG_1STR) void pasteconsole() { -#ifdef _WIN32 +#if defined(OF_WINDOWS) if (!IsClipboardFormatAvailable(CF_TEXT)) return; if (!OpenClipboard(NULL)) @@ -161,7 +161,7 @@ pasteconsole() strcat_s(commandbuf, cb); GlobalUnlock(cb); CloseClipboard(); -#else +#elif !defined(OF_MACOS) SDL_SysWMinfo wminfo; SDL_VERSION(&wminfo.version); wminfo.subsystem = SDL_SYSWM_X11; diff --git a/src/cube.h b/src/cube.h index 9b293b2..70fd190 100644 --- a/src/cube.h +++ b/src/cube.h @@ -460,9 +460,17 @@ enum // function signatures for script functions, see command.cpp #include -#include -#include -#include +#ifdef OF_MACOS +# define GL_SILENCE_DEPRECATION +# define GL_EXT_texture_env_combine 1 +# include +# include +# include +#else +# include +# include +# include +#endif #include #include diff --git a/src/editing.mm b/src/editing.mm index eee19d8..0834575 100644 --- a/src/editing.mm +++ b/src/editing.mm @@ -14,7 +14,7 @@ block sel; OF_CONSTRUCTOR() { enqueueInit(^{ - sel = { + sel = (block){ variable(@"selx", 0, 0, 4096, &sel.x, NULL, false), variable(@"sely", 0, 0, 4096, &sel.y, NULL, false), variable(@"selxs", 0, 0, 4096, &sel.xs, NULL, false), diff --git a/src/meson.build b/src/meson.build index 6b9c022..463b951 100644 --- a/src/meson.build +++ b/src/meson.build @@ -36,7 +36,7 @@ executable('client', ], dependencies: [ objfw_dep, - sdl12_dep, + sdl_dep, sdlimage_dep, sdlmixer_dep, zlib_dep, @@ -57,7 +57,7 @@ executable('server', objcpp_args: ['-DSTANDALONE'], dependencies: [ objfw_dep, - sdl12_dep + sdl_dep ], include_directories: [enet_includes], link_args: server_link_args,