macOS support (Apple Silicon + Intel) - #6
Open
paranoidminotaur wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Rendering —
olcPixelGameEngineauto-selected the GLUT backend on macOS.Modern macOS deprecates GLUT and
glutGet(GLUT_SCREEN_WIDTH)returns 0, which causedthe 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 topof SDL2) for joystick support. On macOS, both
libSDL-1.2andlibSDL2exportidentical 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_PollEventloop never saw standardSDL_KEYDOWNor
SDL_MOUSEMOTIONevents — only opaque custom-type events it didn't know about.Audio —
SoundPlayer(the first member constructed inNestrisX86) calledMix_OpenAudiobeforeSDL_Inithad been called by anything else. On someconfigurations this silently failed.
CMake — Homebrew paths were hardcoded to
/opt/homebrew, which is the AppleSilicon prefix. Intel Macs use
/usr/local.Changes
CMakeLists.txt/opt/homebrewpaths withfind_package(SDL2),find_package(SDL2_mixer), andfind_package(yaml-cpp), which work on both Inteland Apple Silicon via their installed CMake config files.
sdl12-compat(libSDL-1.2) from the macOS and Linux link entirely.libsdl2-devreplaceslibsdl1.2-dev).Build instructions are now: