diff options
| author | skal <pascal.massimino@gmail.com> | 2026-03-26 07:34:54 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-03-26 07:34:54 +0100 |
| commit | f7a34b7401695a4a9137889eb4eb322694f8c5c9 (patch) | |
| tree | 19e165da848a412641312b2d8e6fd4d49266732b /src/platform/platform.cc | |
| parent | af70b169c3d65c053ed80dd85e85304dfa78dc35 (diff) | |
fix(src/platform): code review cleanup
- platform.h: deduplicate str_view/label_view/platform_wgpu_wait_any
(were identical in WIN32 and default branches); remove dead
platform_wgpu_set_error_callback and its never-used callback typedefs
- platform.cc: remove glfwSetWindowUserPointer(nullptr) + stale comment
block; drop if-guard on user pointer fixup in platform_poll; remove
redundant aspect_ratio recompute (framebuffer_size_callback owns it)
- headless_platform.cc: write g_virtual_time back to state->time in
platform_poll; remove never-set g_should_close variable
- stub_types.h: remove dead platform_wgpu_set_error_callback and
callback typedefs; add comment on non-empty WGPURenderPassColorAttachment
handoff(Gemini): platform layer cleaned up, no behaviour change
Diffstat (limited to 'src/platform/platform.cc')
| -rw-r--r-- | src/platform/platform.cc | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/src/platform/platform.cc b/src/platform/platform.cc index 29b3af3..ce9ec41 100644 --- a/src/platform/platform.cc +++ b/src/platform/platform.cc @@ -52,16 +52,8 @@ PlatformState platform_init(bool fullscreen, int width, int height) { state.aspect_ratio = (float)state.width / (float)state.height; } - // Store our state in a static pointer or use the window pointer? - // We'll use a pointer to a persistent state. - // For this demo, we can assume the PlatformState persists in main(). - // But we return by value. This is a bit tricky with callbacks. - // We'll fix the callbacks in platform_poll if needed, or just let main pass - // the pointer back. - - glfwSetWindowUserPointer(state.window, - nullptr); // Will be set in main's state - + // User pointer is set on first platform_poll() when the caller's + // PlatformState address is stable. glfwSetKeyCallback(state.window, glfw_key_callback); glfwSetFramebufferSizeCallback(state.window, framebuffer_size_callback); @@ -88,16 +80,9 @@ void platform_shutdown(PlatformState* state) { } void platform_poll(PlatformState* state) { - // Ensure the window has the current state pointer for callbacks - if (glfwGetWindowUserPointer(state->window) != state) { - glfwSetWindowUserPointer(state->window, state); - } - + glfwSetWindowUserPointer(state->window, state); glfwPollEvents(); state->time = glfwGetTime(); - if (state->height > 0) { - state->aspect_ratio = (float)state->width / (float)state->height; - } } bool platform_should_close(PlatformState* state) { |
