Skip to content

Fix window resize stretching the canvas instead of resizing the sketch surface (#127)#170

Open
arrxy wants to merge 11 commits into
processing:mainfrom
arrxy:main
Open

Fix window resize stretching the canvas instead of resizing the sketch surface (#127)#170
arrxy wants to merge 11 commits into
processing:mainfrom
arrxy:main

Conversation

@arrxy

@arrxy arrxy commented Jun 25, 2026

Copy link
Copy Markdown

Fix: #127

Both bugs stem from the same root confusion: logical vs. physical pixels. @catilac

Summary

Two rendering issues with a shared cause in how window dimensions were
interpreted.

Fix 1 Resize stretched the canvas instead of reflowing it

Root cause: Bevy's WinitPlugin is disabled (we use a GLFW backend), so
nothing emitted WindowResized. Without that event:

  • bevy_render's camera_system never ran on resize
  • the camera's Projection stayed pinned to the original size
  • the render target was simply scaled to fit — the "stretch"
  • width/height (SurfaceSize) were left stale

Fix: sync_to_surface now emits WindowResized itself whenever a window's
physical size actually changes.

Fix 2 macOS Retina rendered 400×400 sketches as 800×800

Root cause: the camera's ProcessingProjection (the sketch's coordinate
space) was built from physical dimensions (width × scale_factor = 800 on a
2× display) instead of the logical size (400), doubling everything.

Fix: use logical width/height for the projection and SurfaceSize;
reserve physical dimensions for the GPU texture (Extent3d) and readback buffer
only.

@arrxy arrxy marked this pull request as ready for review June 25, 2026 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Window resize stretches canvas instead of resizing sketch surface

1 participant