Skip to content

macOS support (Apple Silicon + Intel) - #6

Open
paranoidminotaur wants to merge 2 commits into
rosskidson:masterfrom
paranoidminotaur:apple-silicon
Open

macOS support (Apple Silicon + Intel)#6
paranoidminotaur wants to merge 2 commits into
rosskidson:masterfrom
paranoidminotaur:apple-silicon

Conversation

@paranoidminotaur

Copy link
Copy Markdown

macOS support (Apple Silicon + Intel)

The game previously built on macOS but rendered a black window via the broken GLUT
backend, had no keyboard or gamepad input, and had no audio. This PR fixes all of
that and cleans up a few rough edges along the way.

Tested on macOS 15 (Sequoia) with Apple Silicon (M3). The CMake changes should work
on Intel Macs without modification.


What was broken and why

RenderingolcPixelGameEngine auto-selected the GLUT backend on macOS.
Modern macOS deprecates GLUT and glutGet(GLUT_SCREEN_WIDTH) returns 0, which caused
the engine to exit immediately. Even when patched past that, the GLUT window rendered
nothing.

Keyboard/gamepad input — The project linked sdl12-compat (an SDL 1.2 shim on top
of SDL2) for joystick support. On macOS, both libSDL-1.2 and libSDL2 export
identical symbol names and share one event queue. sdl12-compat registers a block of
custom SDL2 event type IDs at startup and re-injects all incoming events under those
IDs, so the rendering backend's SDL_PollEvent loop never saw standard SDL_KEYDOWN
or SDL_MOUSEMOTION events — only opaque custom-type events it didn't know about.

AudioSoundPlayer (the first member constructed in NestrisX86) called
Mix_OpenAudio before SDL_Init had been called by anything else. On some
configurations this silently failed.

CMake — Homebrew paths were hardcoded to /opt/homebrew, which is the Apple
Silicon prefix. Intel Macs use /usr/local.


Changes

CMakeLists.txt

  • Replaced hardcoded /opt/homebrew paths with find_package(SDL2),
    find_package(SDL2_mixer), and find_package(yaml-cpp), which work on both Intel
    and Apple Silicon via their installed CMake config files.
  • Removed sdl12-compat (libSDL-1.2) from the macOS and Linux link entirely.
  • Updated Linux apt dependencies in comments (libsdl2-dev replaces libsdl1.2-dev).

Build instructions are now:

# macOS
brew install libpng sdl2 sdl2_mixer yaml-cpp

# Linux
sudo apt install libpng-dev libsdl2-dev libsdl2-mixer-dev libyaml-cpp-dev libgl-dev

mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
./nestris_x86   # run from project root

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant