From 5e33097e4649f1c886275db18dc532930487457b Mon Sep 17 00:00:00 2001 From: skal Date: Sat, 14 Feb 2026 12:50:27 +0100 Subject: 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 --- src/tests/common/test_3d_helpers.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/tests/common/test_3d_helpers.h (limited to 'src/tests/common/test_3d_helpers.h') 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 + +// 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); -- cgit v1.2.3