Initial port to macOS

Doesn't work yet as SDL1 is broken on modern macOS.

FossilOrigin-Name: f5b62f82030659a511f4add8212857fca598c6cef86a3238705eb60e35011631
This commit is contained in:
Jonathan Schleifer 2025-03-04 23:03:58 +00:00
parent 9782fa9b54
commit c3cd8d4fac
6 changed files with 26 additions and 13 deletions

View file

@ -9,7 +9,10 @@ add_global_arguments(
language: 'objcpp') language: 'objcpp')
objfw_dep = dependency('objfw') 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') sdlimage_dep = dependency('SDL_image')
sdlmixer_dep = dependency('SDL_mixer') sdlmixer_dep = dependency('SDL_mixer')
zlib_dep = dependency('zlib') zlib_dep = dependency('zlib')
@ -21,6 +24,8 @@ extra_deps = []
if host_machine.system() == 'windows' if host_machine.system() == 'windows'
client_link_args += ['-lopengl32', '-lglu32', '-lwinmm'] client_link_args += ['-lopengl32', '-lglu32', '-lwinmm']
server_link_args += ['-lwinmm'] server_link_args += ['-lwinmm']
elif host_machine.system() == 'darwin'
extra_deps += dependency('OpenGL', method: 'extraframework')
else else
extra_deps += dependency('gl') extra_deps += dependency('gl')
extra_deps += dependency('glu') extra_deps += dependency('glu')

View file

@ -122,7 +122,7 @@ int framesinmap = 0;
{'n', @"server-desc", 1, NULL, &sdesc}, {'i', @"ip", 1, NULL, &ip}, {'n', @"server-desc", 1, NULL, &sdesc}, {'i', @"ip", 1, NULL, &ip},
{'m', @"master", 1, NULL, &master}, {'m', @"master", 1, NULL, &master},
{'p', @"password", 1, NULL, &passwd}, {'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 *optionsParser =
[OFOptionsParser parserWithOptions:options]; [OFOptionsParser parserWithOptions:options];
OFUnichar option; OFUnichar option;

View file

@ -45,10 +45,10 @@ conline(const char *sf, bool highlight) // add a line to the console buffer
strcpy_s(cl.cref, sf); strcpy_s(cl.cref, sf);
}; };
puts(cl.cref); puts(cl.cref);
#ifndef _WIN32 #ifndef OF_WINDOWS
fflush(stdout); fflush(stdout);
#endif #endif
}; }
void void
conoutf(OFString *str, ...) conoutf(OFString *str, ...)
@ -144,7 +144,7 @@ mapmsg(OFString *s)
} }
COMMAND(mapmsg, ARG_1STR) COMMAND(mapmsg, ARG_1STR)
#ifndef _WIN32 #if !defined(OF_WINDOWS) && !defined(OF_MACOS)
# include <SDL_syswm.h> # include <SDL_syswm.h>
# include <X11/Xlib.h> # include <X11/Xlib.h>
#endif #endif
@ -152,7 +152,7 @@ COMMAND(mapmsg, ARG_1STR)
void void
pasteconsole() pasteconsole()
{ {
#ifdef _WIN32 #if defined(OF_WINDOWS)
if (!IsClipboardFormatAvailable(CF_TEXT)) if (!IsClipboardFormatAvailable(CF_TEXT))
return; return;
if (!OpenClipboard(NULL)) if (!OpenClipboard(NULL))
@ -161,7 +161,7 @@ pasteconsole()
strcat_s(commandbuf, cb); strcat_s(commandbuf, cb);
GlobalUnlock(cb); GlobalUnlock(cb);
CloseClipboard(); CloseClipboard();
#else #elif !defined(OF_MACOS)
SDL_SysWMinfo wminfo; SDL_SysWMinfo wminfo;
SDL_VERSION(&wminfo.version); SDL_VERSION(&wminfo.version);
wminfo.subsystem = SDL_SYSWM_X11; wminfo.subsystem = SDL_SYSWM_X11;

View file

@ -460,9 +460,17 @@ enum // function signatures for script functions, see command.cpp
#include <time.h> #include <time.h>
#ifdef OF_MACOS
# define GL_SILENCE_DEPRECATION
# define GL_EXT_texture_env_combine 1
# include <OpenGL/gl.h>
# include <OpenGL/glext.h>
# include <OpenGL/glu.h>
#else
# include <GL/gl.h> # include <GL/gl.h>
# include <GL/glext.h> # include <GL/glext.h>
# include <GL/glu.h> # include <GL/glu.h>
#endif
#include <SDL.h> #include <SDL.h>
#include <SDL_image.h> #include <SDL_image.h>

View file

@ -14,7 +14,7 @@ block sel;
OF_CONSTRUCTOR() OF_CONSTRUCTOR()
{ {
enqueueInit(^{ enqueueInit(^{
sel = { sel = (block){
variable(@"selx", 0, 0, 4096, &sel.x, NULL, false), variable(@"selx", 0, 0, 4096, &sel.x, NULL, false),
variable(@"sely", 0, 0, 4096, &sel.y, NULL, false), variable(@"sely", 0, 0, 4096, &sel.y, NULL, false),
variable(@"selxs", 0, 0, 4096, &sel.xs, NULL, false), variable(@"selxs", 0, 0, 4096, &sel.xs, NULL, false),

View file

@ -36,7 +36,7 @@ executable('client',
], ],
dependencies: [ dependencies: [
objfw_dep, objfw_dep,
sdl12_dep, sdl_dep,
sdlimage_dep, sdlimage_dep,
sdlmixer_dep, sdlmixer_dep,
zlib_dep, zlib_dep,
@ -57,7 +57,7 @@ executable('server',
objcpp_args: ['-DSTANDALONE'], objcpp_args: ['-DSTANDALONE'],
dependencies: [ dependencies: [
objfw_dep, objfw_dep,
sdl12_dep sdl_dep
], ],
include_directories: [enet_includes], include_directories: [enet_includes],
link_args: server_link_args, link_args: server_link_args,