summaryrefslogtreecommitdiff
path: root/src/tests/common/test_3d_helpers.h
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-14 12:50:27 +0100
committerskal <pascal.massimino@gmail.com>2026-02-14 12:50:27 +0100
commit5e33097e4649f1c886275db18dc532930487457b (patch)
treee4cee838e54a2aaf8fa66741f467f8fceefc808a /src/tests/common/test_3d_helpers.h
parent48beb6b1c10d7ca42205000a5bb420a1e3282d92 (diff)
Refactor: factorize WGPU init code for 3D tests
Extracted duplicate WGPU initialization boilerplate from test_3d_physics, test_3d_render, and test_mesh into shared helper (test_3d_helpers). **Changes:** - New: src/tests/common/test_3d_helpers.{h,cc} (~120 LOC) - Removed ~280 LOC of duplicate init_wgpu() implementations - Net savings: -141 LOC **Benefits:** - Single source of truth for surface+device initialization - Eliminates cross-compile #ifdef duplication - Easier maintenance for callback API changes All 34 tests pass. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/tests/common/test_3d_helpers.h')
-rw-r--r--src/tests/common/test_3d_helpers.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/tests/common/test_3d_helpers.h b/src/tests/common/test_3d_helpers.h
new file mode 100644
index 0000000..5e9c72c
--- /dev/null
+++ b/src/tests/common/test_3d_helpers.h
@@ -0,0 +1,20 @@
+// This file is part of the 64k demo project.
+// Common WGPU initialization for 3D visual tests with surfaces.
+
+#pragma once
+
+#include "platform/platform.h"
+#include <webgpu.h>
+
+// Result of WGPU initialization with surface
+struct WgpuSurfaceContext {
+ WGPUDevice device;
+ WGPUQueue queue;
+ WGPUSurface surface;
+ WGPUAdapter adapter;
+ WGPUTextureFormat format;
+};
+
+// Initialize WGPU with surface for rendering tests
+// Returns context with device/queue/surface/adapter/format
+WgpuSurfaceContext init_wgpu_with_surface(PlatformState* platform_state);