summaryrefslogtreecommitdiff
path: root/src/platform/headless_platform.cc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-09 19:34:46 +0100
committerskal <pascal.massimino@gmail.com>2026-02-09 19:34:46 +0100
commitf449fe7f78e059d455dfefcf4b09d763363f6344 (patch)
tree0a1e6ebfc42025e4e72200d3c34e2bf799a32aa8 /src/platform/headless_platform.cc
parentdd42eeef53df8ea36f436986f915f29986c094a3 (diff)
feat: Add headless mode for testing without GPU
Implements DEMO_HEADLESS build option for fast iteration cycles: - Functional GPU/platform stubs (not pure no-ops like STRIP_EXTERNAL_LIBS) - Audio and timeline systems work normally - No rendering overhead - Useful for CI, audio development, timeline validation Files added: - doc/HEADLESS_MODE.md - Documentation - src/gpu/headless_gpu.cc - Validated GPU stubs - src/platform/headless_platform.cc - Time simulation (60Hz) - scripts/test_headless.sh - End-to-end test script Usage: cmake -B build_headless -DDEMO_HEADLESS=ON cmake --build build_headless -j4 ./build_headless/demo64k --headless --duration 30 Progress printed every 5s. Compatible with --dump_wav mode. handoff(Claude): Task #76 follow-up - headless mode complete
Diffstat (limited to 'src/platform/headless_platform.cc')
-rw-r--r--src/platform/headless_platform.cc60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/platform/headless_platform.cc b/src/platform/headless_platform.cc
new file mode 100644
index 0000000..4ec8c5d
--- /dev/null
+++ b/src/platform/headless_platform.cc
@@ -0,0 +1,60 @@
+// Headless platform - time simulation without window
+// Workspace: demo (shared across all workspaces)
+
+#if defined(DEMO_HEADLESS)
+
+#include "platform.h"
+#include "stub_types.h"
+#include <stdio.h>
+
+static double g_virtual_time = 0.0;
+static bool g_should_close = false;
+static const double FRAME_TIME = 1.0 / 60.0;
+
+PlatformState platform_init(bool fullscreen, int width, int height) {
+ (void)fullscreen;
+ g_virtual_time = 0.0;
+ g_should_close = false;
+ printf("[headless] Platform initialized (simulated %dx%d)\n", width, height);
+
+ PlatformState state = {};
+ state.width = width;
+ state.height = height;
+ state.aspect_ratio = (float)width / (float)height;
+ state.window = nullptr;
+ state.time = 0.0;
+ state.is_fullscreen = false;
+ return state;
+}
+
+void platform_shutdown(PlatformState* state) {
+ (void)state;
+ printf("[headless] Platform shutdown\n");
+}
+
+void platform_poll(PlatformState* state) {
+ (void)state;
+ g_virtual_time += FRAME_TIME;
+}
+
+bool platform_should_close(PlatformState* state) {
+ (void)state;
+ return g_should_close;
+}
+
+void platform_toggle_fullscreen(PlatformState* state) {
+ (void)state;
+}
+
+WGPUSurface platform_create_wgpu_surface(WGPUInstance instance,
+ PlatformState* state) {
+ (void)instance;
+ (void)state;
+ return nullptr;
+}
+
+double platform_get_time() {
+ return g_virtual_time;
+}
+
+#endif // DEMO_HEADLESS