Supported Platforms
Linux
Production-ready support via X11
Web/WASM
WebAssembly support via Emscripten
macOS
Planned support (implementation exists)
Windows
Planned support (not yet implemented)
Platform Detection
Fern uses CMake preprocessor definitions to detect the target platform at compile-time:CMakeLists.txt:13-27
Platform Renderer Factory
The framework uses a factory pattern to instantiate the correct renderer based on compile-time platform detection:platform_factory.cpp:16-28
Platform-Specific Source Files
Each platform has its own renderer implementation:platform_factory.cpp) conditionally includes only the relevant renderer based on compilation flags.
Build System Support
Fern provides multiple build options:CMake Build
The primary build system uses CMake to detect platforms and configure compilation:Shell Script Build
For quick builds on Linux and Web, use the provided build script:build.sh
Fern CLI
For Web development with live reload:Platform Renderer Interface
All platform renderers implement thePlatformRenderer interface, which provides:
- Initialization:
initialize(width, height) - Rendering:
present(pixelBuffer, width, height) - Event handling: Mouse, keyboard, resize callbacks
- Window management:
setTitle(),setSize(),shouldClose() - Event polling:
pollEvents()
The Web platform uses event listeners instead of polling, while native platforms (Linux, macOS) use event polling in the main loop.
Next Steps
Linux Setup
Learn about X11 dependencies and Linux-specific configuration
Web/WASM Setup
Compile to WebAssembly with Emscripten