Skip to content

Implement resizable windows with main-thread cached presentation - #198

Open
genixpro wants to merge 7 commits into
masterfrom
codex/resize-layout-foundation
Open

Implement resizable windows with main-thread cached presentation#198
genixpro wants to merge 7 commits into
masterfrom
codex/resize-layout-foundation

Conversation

@genixpro

@genixpro genixpro commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Windowed Glob2 can now resize while retaining its OpenGL context and sprite textures. Editor controls and minimap hitboxes follow the logical width, normal screens reflow, and overlay dialogs stay within the parent bounds. During Windows modal resizing, an exposed-event callback presents the last completed frame; normal polling applies the final OS dimensions and resumes drawing.

Credit to Nathan Mills (@Quipyowert2) for the editor anchoring, minimap positioning, and frame extraction in #64. The foundation commit includes his co-author attribution. This implementation adapts that groundwork to current master and keeps the event loop, rendering, and simulation on one thread.

Implementation

  • Own the logical drawing surface, and apply OS size changes without calling SDL_SetWindowSize or recreating the GL context.
  • Cache completed GL frames before swapping and completed software frames in an owned surface. Expose callbacks only present that cache, preserving GL attributes/matrices and avoiding timer, simulation, cursor, or particle updates.
  • Restrict callbacks to the owning thread and active event pump, reject recursion and foreign windows, and remove watchers/caches before window recreation or destruction.
  • Preserve fullscreen aspect scaling, minimum dimensions, input conversion, and master's hit-boundary fixes. Scale modal backdrops and constrain overlay placement when the window shrinks.
  • Require SDL 2.30+ at runtime for Windows clients, which provides the modal-loop expose events.
  • Add resize-test integration coverage and run both backends in Linux CI. docs/window-resizing.md describes ownership, timing, behavior, and remaining acceptance checks.

Validation

  • macOS and Windows client builds passed; all three CI jobs passed on tested code commit 71da3dbbc (Ubuntu 22.04, Ubuntu 24.04, Windows MinGW). The final acceptance-results commit only changes documentation.
  • Rebuilt CppUnit runner: 161 tests passed.
  • WindowResizeHarness software and gl passed: cached pixels survive incomplete drawing, callback guards, no normal-frame advancement from exposes, GL state restoration, grow/shrink reflow, context identity, input coordinates, minimum size, and cache invalidation/rendering after window recreation.
  • FullscreenAspectHarness software and gl passed at five dimensions: aspect preservation, clipping, screen capture, and mouse mapping.
  • Windows Server 2022 desktop VM: both resize harness backends passed with SDL 2.32.10, including OpenGL 1.1 GDI Generic. Native testing caught and fixed an unsupported texture-wrap mode and a missing explicit return in the Windows SDL test entry point.
  • Linux X11/Mesa llvmpipe: both resize harness backends passed. GL pixel checks now capture the submitted back buffer at the swap boundary, avoiding unreliable post-swap front-buffer readback under Xvfb.
  • Windows native edge dragging and sustained system-menu sizing passed in the interactive harness: 357 cached presentations occurred while the normal frame count remained unchanged. Maximize/restore retained the image and resumed drawing.
  • Full Windows client smoke tests passed in software mode and Mesa OpenGL: main-menu reflow, map loading, editor resize to minimum width, relocated menu hitbox, open-menu clamping/input after shrinking (software), and relocated minimap navigation (both modes). The full client requires newer GL features than GDI Generic, so the VM uses app-local Mesa libraries for this check.
  • Native macOS edge-drag smoke test: main menu resized and reflowed without visible texture corruption.
  • Headless smoke test: --nox games/gd-small-2ai.game 10 1 completed with checksum cda93c80.
  • git diff --check passed.

Final Windows acceptance pass

  • Two full Windows clients played SmallForTwo over real loopback TCP. Both host and guest recovered after short, ten-second, and greater-than-sixty-second native sizing pauses. Peers displayed the waiting message, then resumed; both accepted building-priority orders afterward. The guest left normally and the host received victory.
  • All 6,371 shared simulation ticks matched, including total/team/unit/building checksum records. There were zero mismatches. Separate replay/checksum files were retained in the validation VM.
  • Enabled Windows Show window contents while dragging as well as the RDP option. The initial short/ten-second host checks used outline resizing; the sustained host test and all guest tests used full-window contents.
  • Tutorial checks passed in software and Mesa GL: grow/shrink down to 640x480, maximize, drag down to restore, minimize/taskbar-restore, and advance messages. No persistent white textures, blank regions, or duplicated sidebar edges appeared in inspected frames.
  • Nested tutorial Save (GL) and Load (software) dialogs remained usable through resizing and accepted Cancel afterward.
  • Software fullscreen/windowed switching passed live. GL fullscreen startup and settings input passed; GL display changes retain master's existing restart requirement.
  • No production code fixes were needed during this final acceptance pass. Details and coverage limits are in docs/window-resizing.md.

Behavior and coverage limits

Ready for review. Windows modal sizing pauses simulation and displays the cached frame until the drag ends; the tested LAN match recovered without desynchronization. This does not promise uninterrupted multiplayer simulation during a drag. Existing pacing bounds catch-up to 500 ms.

The VM tests use CPU-rendered OpenGL and loopback networking. Physical Windows GPU drivers, mixed-DPI multi-monitor transitions, Internet latency/packet loss, and public YOG-server behavior remain unverified coverage, not known failures. The tutorial pass covers the original resize scenarios rather than the entire campaign. Frames beyond the GL maximum cache texture size retain normal rendering but cannot use cached expose presentation.

Adapt the right-edge anchoring, minimap positioning, and editor frame
extraction from Nathan Mills's PR #64 to the current source layout.
Keep drawing and hit testing on one shared widget rectangle and refresh
minimap coordinates before input as well as painting.

Document a follow-up design using main-thread cached-frame presentation
for modal resize callbacks. This change does not enable live resizing.

Co-authored-by: Nathan Mills <38995150+Quipyowert2@users.noreply.github.com>
@genixpro
genixpro requested a review from Giszmo September 8, 2026 01:33
@genixpro
genixpro marked this pull request as draft September 8, 2026 01:35
@genixpro genixpro changed the title Extract resize layout groundwork from #64 and propose main-thread presentation Implement resizable windows with main-thread cached presentation Sep 8, 2026
@genixpro
genixpro marked this pull request as ready for review September 8, 2026 03:15
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.

1 participant