[Major Feature] True headless execution without X11/GPU dependencies #157
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Blocks
Reference
john/McRogueFace#157
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem Statement
McRogueFace cannot execute on servers without X11, even with
--headlessmode. The current headless implementation avoids creating a window but still requires the full graphics stack:This prevents use cases like:
Root Cause Analysis
SFML's architecture is the fundamental blocker.
sf::RenderTexture::create()unconditionally initializes an OpenGL context, which on Linux requires X11 libraries and a display.Current Dependencies
From
CMakeLists.txt:sfml-graphics(requires OpenGL)sfml-window(requires X11/udev on Linux)sfml-system(no graphics deps - safe)sfml-audio(already disabled in headless)OpenGL::GL(required by ImGui-SFML)SFML Type Pervasiveness
sf::types across codebaseUIDrawable::render(sf::Vector2f, sf::RenderTarget&)sf::Vector2f,sf::Color,sf::FloatRect,sf::Font,sf::TextureRequirements
Potential Approaches
Option A: Software Rasterizer Backend
Replace OpenGL with a CPU-based renderer (Cairo, Skia, or custom).
Pros:
Cons:
Option B: Conditional Compilation (Dual Binary)
Build two versions:
mcrogueface(full) andmcrogueface-headless(minimal).Pros:
Cons:
Option C: Abstract Renderer Interface + Pluggable Backends
Create
RenderBackendabstraction with multiple implementations:SFMLBackend- current behavior (requires X11)SoftwareBackend- CPU rendering (no X11)NullBackend- no rendering (fastest, no screenshots)Pros:
Cons:
Option D: Offscreen Mesa/OSMesa
Use Mesa's software OpenGL implementation.
Pros:
Cons:
Option E: Wait for SFML 3.x
SFML 3.0 may have better headless support.
Pros:
Cons:
Recommended Path
Option C (Abstract Renderer) with Option A (Software Rasterizer) as the headless backend.
This is the most future-proof approach but also the largest undertaking. It would:
RenderTargetinterface (or wrapper around sf::RenderTarget)SoftwareRendererusing a library like:HeadlessRendererpathwayScope Estimate
This is a Major Feature requiring:
Not suitable for near-term v1.0 timeline. Should be planned as a post-1.0 enhancement or parallel long-term effort.
Workaround (Current)
For immediate needs, use virtual framebuffer:
Or in Docker:
Related
src/HeadlessRenderer.h/cpp)References
Note: libtcod-headless Already Exists
The project already maintains a fork of libtcod without SDL dependencies: https://github.com/jmccardle/libtcod-headless
This means libtcod is not a blocker for true headless execution. The dependency situation is simpler than initially assessed:
SFML is the sole blocker. The renderer abstraction work is the critical path for headless support.
This also has implications for future WASM/Emscripten builds — libtcod-headless should cross-compile cleanly without SDL concerns.
Cross-Reference: Emscripten Research
Research on #158 (Emscripten) confirms that renderer abstraction is shared prerequisite work.
See
docs/EMSCRIPTEN_RESEARCH.mdon branchemscripten-mcroguefacefor:The
HeadlessRendererpattern already demonstrates the correct abstraction approach. A true headless backend (Option C from this issue) would:RenderBackendinterface as SFML backendsf::RenderTarget*pointer pattern already in placeBoth #157 and #158 benefit from the same Phase 3 work: Render Backend Interface.
Implemented across multiple commits:
7621ae3and4c70aeeaddedMCRF_HEADLESScompile-time option,src/platform/HeadlessTypes.hprovides no-op type stubs, andGLContext_Headless.cpphandles headless GL context.makefrom project root builds the standard target; headless builds use-DMCRF_HEADLESS=ON. The--headless --execmode runs without a display server and is used extensively in CI/testing (50+ test files).