Created
July 2, 2025 16:08
-
-
Save attic-stuff/9fe7b76391953ebb8362562f6b01f2f2 to your computer and use it in GitHub Desktop.
converts a region in the room to a gpu scissor region
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
| /** | |
| * converts a room region to a gpu scissor region | |
| * @param {real} x the x position of the region origin | |
| * @param {real} y the y position of the region origin | |
| * @param {real} width the width of the region | |
| * @param {real} height the height of the region | |
| * @return {struct} | |
| */ | |
| function room_region_to_scissor_region(x, y, width, height) { | |
| static scissor_struct = { x: infinity, y: infinity, w: infinity, h: infinity }; | |
| var current_view = camera_get_active(); | |
| var view_width = camera_get_view_width(current_view); | |
| var view_height = camera_get_view_height(current_view); | |
| var view_x = camera_get_view_x(view_camera[current_view]); | |
| var view_y = camera_get_view_y(view_camera[current_view]); | |
| var render_width = surface_get_width(application_surface); | |
| var render_height = surface_get_height(application_surface); | |
| var scale_x = render_width / view_width; | |
| var scale_y = render_height / view_height; | |
| scissor_struct.x = (x - view_x) * scale_x; | |
| scissor_struct.y = (y - view_y) * scale_y; | |
| scissor_struct.w = width * scale_x; | |
| scissor_struct.h = height * scale_y; | |
| return scissor_struct; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment