A game pixel can be drawn as more than one screen pixel - #49
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #39.
What changed.
screen-scaleinrwe.cfg(or--screen-scale), 1 to 4, default 1:GlobalConfig::screenScale.SceneManager: above 1, the sharedViewportthe 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 presentationFrameBufferInfoof that size, and at the end of the frame it is blitted onto the window withGL_NEAREST. Mouse button and motion events are divided by the scale before dispatch; wheel deltas are not.GraphicsContext:setPresentationFrameBuffermakesunbindFrameBufferreturn to the frame's buffer instead of the window, soGameScene::renderWorld's own offscreen pass keeps working without knowing about the scale;blitFrameBufferToWindowdoes the blow-up.CursorServiceandGameScene::getMousePositionread the mouse from SDL directly, so both divide by the scale.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.--screen-scale 1and--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.🤖 Generated with Claude Code
https://claude.ai/code/session_01PJCbwC9MGZnM6erMDKptun