Skip to content

view_set_viewport: keep fractions in roomRectX/Y/W/H - #808

Merged
rwkay merged 1 commit into
developfrom
features/view-set-viewport-room-rect-fractions
Nov 21, 2026
Merged

rwkay merged 1 commit into
developfrom
features/view-set-viewport-room-rect-fractions

Conversation

@rwkay

@rwkay rwkay commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #806 and #807 (view_set_viewport, non-rectangular viewports, https://github.com/YoYoGames/GMS2-Runner-Main/issues/1076).

view_set_viewport read every field with yyGetInt32, so roomRectX: 10.5 became 10. The room rectangle is the view's camera, and camera_set_view_pos and the other camera functions take reals. The roomRect* fields are now read as reals. The screen* fields are the port, in pixels, so they stay whole numbers.

I also checked the JSON string form, and it needs no change. It calls the runner's own json_parse (Function_File.js), the same function GML's json_parse uses. So it accepts exactly what json_parse accepts, comments and trailing commas included where json_parse allows them.

Tests: BasicViewSetViewportTestSuite from YoYoGames/GM-TestFramework#386 at f511079, raw build, headless Chrome. There were no console errors.

App surface Screen Keeps left-out fields Surface port-sized Polygon off from Draw Errors
WebGL, this branch Passed (11) Passed (7) Passed (20) Passed (5) Passed (2) Passed (17)
Canvas, this branch Passed (11) Passed (7) Passed (20) Passed (5) Passed (2) Passed (17)
WebGL and Canvas, develop 21d8f87 Passed Passed Failed (camera_get_view_x was 10, not 10.5) Passed Passed Passed

The room rectangle is the view's camera, and camera_set_view_pos and friends take reals, but
view_set_viewport read every field with yyGetInt32, so roomRectX: 10.5 became 10. The roomRect
fields are now read as reals; the screen fields (the port, in pixels) stay whole numbers.

Found by GM-TestFramework#386 at f511079.

Claude-Session: https://claude.ai/code/session_01EgTASfpMoBvX7TBDy119t5
@rwkay
rwkay requested a review from iampremo November 21, 2026 19:20
@gm-auto-review

Copy link
Copy Markdown

Automated review

This PR changes view_set_viewport so the roomRectX/Y/W/H fields are read with yyGetReal rather than yyGetInt32. Fractional room-rectangle values now reach view_xview/view_yview/view_wview/view_hview and the camera unchanged. The screen* port fields are still read as whole numbers.

This matches how camera_set_view_pos and camera_set_view_size already take reals. The view_*view arrays have no integer setter for index-based writes, so they already held reals. The code that copies them back into pView.world* (CopyViewsFromArrays, the mouse and view hit tests, room_get_viewport) works on reals without any change. The positive-size check now accepts a width or height between 0 and 1, which used to be truncated to 0 and rejected. That is consistent with the camera functions. The change looks good to merge.

Nothing open.

Reviewed 02fc9e9

Advisory: this check doesn't block merging. It runs again on each push. Reply in a comment's thread if it is wrong, and resolve the thread once it is dealt with: the next review reads both.

@iampremo iampremo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 02fc9e9.

Looks good to me. Reading roomRect* with yyGetReal makes it match camera_set_view_pos/camera_set_view_size. The view arrays were already written through index-based writes with no truncation, so the fractional values carry through CopyViewsFromArrays into pView.world* unchanged. Nothing downstream truncates them with bitwise ops. The screen* fields correctly stay yyGetInt32 for the port.

A small correction to the bot's summary: room_get_viewport only returns the port fields and the visible flag, never the room rectangle, so it isn't affected either way. That doesn't change anything here.

@rwkay
rwkay merged commit 6bedda4 into develop Nov 21, 2026
2 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.

2 participants