Cube  Check-in [f5b62f8203]

Overview
Comment:Initial port to macOS

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

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f5b62f82030659a511f4add8212857fca598c6cef86a3238705eb60e35011631
User & Date: js on 2025-03-04 23:03:58
Other Links: manifest | tags
Context
2025-03-04
23:51
Port to SDL2 check-in: 42d4b57828 user: js tags: trunk
23:03
Initial port to macOS check-in: f5b62f8203 user: js tags: trunk
01:19
Add long options check-in: 9684b46414 user: js tags: trunk
Changes

Modified meson.build from [c35ae25a1c] to [3e8495e9ec].

1
2
3
4
5
6
7
8
9
10
11
12



13
14
15
16
17
18
19
20
21
22
23


24
25
26
27
28
29
30
project('Cube', ['c', 'objcpp'],
  meson_version: '>=1.5.0')

add_global_arguments(
  [
    '-fobjc-arc',
    '-fobjc-arc-exceptions'
  ],
  language: 'objcpp')

objfw_dep = dependency('objfw')
sdl12_dep = dependency('sdl12_compat')



sdlimage_dep = dependency('SDL_image')
sdlmixer_dep = dependency('SDL_mixer')
zlib_dep = dependency('zlib')

client_link_args = []
server_link_args = []
extra_deps = []

if host_machine.system() == 'windows'
  client_link_args += ['-lopengl32', '-lglu32', '-lwinmm']
  server_link_args += ['-lwinmm']


else
  extra_deps += dependency('gl')
  extra_deps += dependency('glu')
  extra_deps += dependency('x11')
endif

subdir('enet')











|
>
>
>











>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
project('Cube', ['c', 'objcpp'],
  meson_version: '>=1.5.0')

add_global_arguments(
  [
    '-fobjc-arc',
    '-fobjc-arc-exceptions'
  ],
  language: 'objcpp')

objfw_dep = dependency('objfw')
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')

client_link_args = []
server_link_args = []
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')
  extra_deps += dependency('x11')
endif

subdir('enet')

Modified src/Cube.mm from [6a23516b89] to [d63e158bb1].

118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
	    {'d', @"dedicated", 0, &dedicated, NULL},
	    {'t', @"window", 0, &windowed, NULL},
	    {'w', @"width", 1, NULL, NULL}, {'h', @"height", 1, NULL, NULL},
	    {'u', @"upload-rate", 1, NULL, NULL},
	    {'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}};
	OFOptionsParser *optionsParser =
	    [OFOptionsParser parserWithOptions:options];
	OFUnichar option;
	while ((option = [optionsParser nextOption]) != '\0') {
		switch (option) {
		case 'w':
			scr_w = optionsParser.argument.longLongValue;







|







118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
	    {'d', @"dedicated", 0, &dedicated, NULL},
	    {'t', @"window", 0, &windowed, NULL},
	    {'w', @"width", 1, NULL, NULL}, {'h', @"height", 1, NULL, NULL},
	    {'u', @"upload-rate", 1, NULL, NULL},
	    {'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}, {'\0', nil, 0, NULL, NULL}};
	OFOptionsParser *optionsParser =
	    [OFOptionsParser parserWithOptions:options];
	OFUnichar option;
	while ((option = [optionsParser nextOption]) != '\0') {
		switch (option) {
		case 'w':
			scr_w = optionsParser.argument.longLongValue;

Modified src/console.mm from [dd3dab2434] to [2a75e21fbb].

41
42
43
44
45
46
47
48
49
50
51

52
53
54
55
56
57
58
		cl.cref[0] = '\f';
		cl.cref[1] = 0;
		strcat_s(cl.cref, sf);
	} else {
		strcpy_s(cl.cref, sf);
	};
	puts(cl.cref);
#ifndef _WIN32
	fflush(stdout);
#endif
};


void
conoutf(OFString *str, ...)
{
	sprintf_sdv(sf, str.UTF8String);
	const char *s = sf;
	int n = 0;







|


<
>







41
42
43
44
45
46
47
48
49
50

51
52
53
54
55
56
57
58
		cl.cref[0] = '\f';
		cl.cref[1] = 0;
		strcat_s(cl.cref, sf);
	} else {
		strcpy_s(cl.cref, sf);
	};
	puts(cl.cref);
#ifndef OF_WINDOWS
	fflush(stdout);
#endif

}

void
conoutf(OFString *str, ...)
{
	sprintf_sdv(sf, str.UTF8String);
	const char *s = sf;
	int n = 0;
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
{
	@autoreleasepool {
		strn0cpy(hdr.maptitle, s.UTF8String, 128);
	}
}
COMMAND(mapmsg, ARG_1STR)

#ifndef _WIN32
# include <SDL_syswm.h>
# include <X11/Xlib.h>
#endif

void
pasteconsole()
{
#ifdef _WIN32
	if (!IsClipboardFormatAvailable(CF_TEXT))
		return;
	if (!OpenClipboard(NULL))
		return;
	char *cb = (char *)GlobalLock(GetClipboardData(CF_TEXT));
	strcat_s(commandbuf, cb);
	GlobalUnlock(cb);
	CloseClipboard();
#else
	SDL_SysWMinfo wminfo;
	SDL_VERSION(&wminfo.version);
	wminfo.subsystem = SDL_SYSWM_X11;
	if (!SDL_GetWMInfo(&wminfo))
		return;
	int cbsize;
	char *cb = XFetchBytes(wminfo.info.x11.display, &cbsize);







|







|








|







140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
{
	@autoreleasepool {
		strn0cpy(hdr.maptitle, s.UTF8String, 128);
	}
}
COMMAND(mapmsg, ARG_1STR)

#if !defined(OF_WINDOWS) && !defined(OF_MACOS)
# include <SDL_syswm.h>
# include <X11/Xlib.h>
#endif

void
pasteconsole()
{
#if defined(OF_WINDOWS)
	if (!IsClipboardFormatAvailable(CF_TEXT))
		return;
	if (!OpenClipboard(NULL))
		return;
	char *cb = (char *)GlobalLock(GetClipboardData(CF_TEXT));
	strcat_s(commandbuf, cb);
	GlobalUnlock(cb);
	CloseClipboard();
#elif !defined(OF_MACOS)
	SDL_SysWMinfo wminfo;
	SDL_VERSION(&wminfo.version);
	wminfo.subsystem = SDL_SYSWM_X11;
	if (!SDL_GetWMInfo(&wminfo))
		return;
	int cbsize;
	char *cb = XFetchBytes(wminfo.info.x11.display, &cbsize);

Modified src/cube.h from [e88df65bda] to [ff82afe0dc].

456
457
458
459
460
461
462







463
464
465

466
467
468
469
470
471
472
# define ZLIB_DLL
#else
# include <dlfcn.h>
#endif

#include <time.h>








#include <GL/gl.h>
#include <GL/glext.h>
#include <GL/glu.h>


#include <SDL.h>
#include <SDL_image.h>

#include <enet/enet.h>

#include <zlib.h>







>
>
>
>
>
>
>
|
|
|
>







456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
# define ZLIB_DLL
#else
# include <dlfcn.h>
#endif

#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/glext.h>
# include <GL/glu.h>
#endif

#include <SDL.h>
#include <SDL_image.h>

#include <enet/enet.h>

#include <zlib.h>

Modified src/editing.mm from [3bf42210f7] to [631eed4fb7].

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// the edge of the map

block sel;

OF_CONSTRUCTOR()
{
	enqueueInit(^{
		sel = {
		    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),
		    variable(@"selys", 0, 0, 4096, &sel.ys, NULL, false),
		};
	});
}







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// the edge of the map

block sel;

OF_CONSTRUCTOR()
{
	enqueueInit(^{
		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),
		    variable(@"selys", 0, 0, 4096, &sel.ys, NULL, false),
		};
	});
}

Modified src/meson.build from [2ab6d94742] to [d4e8fbb8fd].

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
    'worldio.mm',
    'worldlight.mm',
    'worldocull.mm',
    'worldrender.mm',
  ],
  dependencies: [
    objfw_dep,
    sdl12_dep,
    sdlimage_dep,
    sdlmixer_dep,
    zlib_dep,
    extra_deps
  ],
  include_directories: [enet_includes],
  link_args: client_link_args,
  link_with: [enet],
  win_subsystem: 'windows')

executable('server',
  [
    'server.mm',
    'serverms.mm',
    'serverutil.mm',
    'tools.mm',
  ],
  objcpp_args: ['-DSTANDALONE'],
  dependencies: [
    objfw_dep,
    sdl12_dep
  ],
  include_directories: [enet_includes],
  link_args: server_link_args,
  link_with: [enet],
  win_subsystem: 'console')







|




















|





32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
    'worldio.mm',
    'worldlight.mm',
    'worldocull.mm',
    'worldrender.mm',
  ],
  dependencies: [
    objfw_dep,
    sdl_dep,
    sdlimage_dep,
    sdlmixer_dep,
    zlib_dep,
    extra_deps
  ],
  include_directories: [enet_includes],
  link_args: client_link_args,
  link_with: [enet],
  win_subsystem: 'windows')

executable('server',
  [
    'server.mm',
    'serverms.mm',
    'serverutil.mm',
    'tools.mm',
  ],
  objcpp_args: ['-DSTANDALONE'],
  dependencies: [
    objfw_dep,
    sdl_dep
  ],
  include_directories: [enet_includes],
  link_args: server_link_args,
  link_with: [enet],
  win_subsystem: 'console')