Skip to content

A game pixel can be drawn as more than one screen pixel - #49

Merged
CubeB merged 1 commit into
revivalfrom
39-screen-scale
Sep 11, 2026
Merged

CubeB merged 1 commit into
revivalfrom
39-screen-scale

Conversation

@HectorBailey

Copy link
Copy Markdown
Collaborator

Closes #39.

What changed.

  • screen-scale in rwe.cfg (or --screen-scale), 1 to 4, default 1: GlobalConfig::screenScale.
  • SceneManager: above 1, the shared Viewport the scenes read is set to the window's size divided by the scale (at start and on every resize), the frame is drawn into a presentation FrameBufferInfo of that size, and at the end of the frame it is blitted onto the window with GL_NEAREST. Mouse button and motion events are divided by the scale before dispatch; wheel deltas are not.
  • GraphicsContext: setPresentationFrameBuffer makes unbindFrameBuffer return to the frame's buffer instead of the window, so GameScene::renderWorld's own offscreen pass keeps working without knowing about the scale; blitFrameBufferToWindow does the blow-up.
  • CursorService and GameScene::getMousePosition read the mouse from SDL directly, so both divide by the scale.
  • The screenshot is taken after the blow-up (the window is empty before it at a scale) and at the window's size. It now includes the cursor, which it did not before; noted in the code.
  • Not done: the VISUALS page. The issue says later, and VISUALRT has no spare gadget for it.

Verified.

  • rwe_test: all 582 test cases pass (71660 assertions), Linux gcc-14 Debug. Nothing here is unit-testable beyond that; the checks below are visual.
  • A skirmish on Coast To Coast in the same window at --screen-scale 1 and --screen-scale 2, screenshots taken on the same frame via a temporary hook (reverted): at 2 the interface, the world, the commander, a wreck and the cursor are all crisp two-pixel blocks, the sand and the world's anti-aliasing look as they do at 1 only larger, and the cursor is drawn at the mouse's window position. The one-pixel wireframe and selection box are two screen pixels wide by construction.
  • Clicks: the mapping is the same division the cursor uses, so where the cursor is drawn is where the click lands; not exercised with input automation here.
  • The halo and the supersample are resolved inside the frame, before the blow-up, as the issue asks.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PJCbwC9MGZnM6erMDKptun

The original ran at 640x480 and, stretched across a modern display,
shows each of its pixels about two screen pixels wide. RWE drew one to
one, so its one-pixel wireframe and selection box, drawn exactly as the
original draws them, read as too thin beside it. Making the lines
thicker would make them wrong at one to one; the fix is to scale the
whole picture.

An rwe.cfg key, screen-scale, 1 to 4 and 1 by default. Above 1 the
scenes see a viewport of the window's size divided by the scale and
draw the frame, interface and cursor included, into a buffer of that
size, which is then blown up onto the window with nearest-neighbour
sampling so every game pixel is a square block of screen pixels. The
world's own supersample and the building halo are resolved inside that
frame, so they look as they did, only larger. Mouse events, the cursor
and the scene's own mouse reads are mapped back through the same
factor, so a click lands where the cursor is drawn.

The scenes do not know any of this. A scene that binds a buffer of its
own unbinds back to the frame's buffer rather than to the window,
which is what the graphics context's presentation target is for. The
screenshot moves after the blow-up, since the window has nothing on it
until then, and so now has the cursor in it.

Issue: #39

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PJCbwC9MGZnM6erMDKptun
@CubeB
CubeB merged commit a916443 into revival Sep 11, 2026
5 checks passed
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.

Screen scale: draw each game pixel as more than one screen pixel

2 participants