Skip to content

Handle canvas framebuffer scaling. #19844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

luigifcruz
Copy link

This PR addresses an issue where glfwGetWindowSize and glfwGetFramebufferSize were incorrectly reporting the same values, despite the fact that the canvas native and normal dimensions were different. The proposed map is as follows:

glfwGetFramebufferSize() -> Module.canvas.[width, height]
glfwGetWindowSize() -> Module.canvas.[widthNative, heightNative]

This also scales the values returned from getCursorPos.

I thought about automatically resizing the canvas frame buffer size (canvas.[width, height]) according to the glfwGetMonitorContentScale but I imagine this would break a lot of software. The way I implemented this PR only makes a difference when the canvas frame buffer size is manually altered.

Fixes #19842 (?)

@luigifcruz luigifcruz changed the title Handle canvas frambuffer scaling. Handle canvas framebuffer scaling. Jul 12, 2023
@luigifcruz luigifcruz marked this pull request as draft July 12, 2023 03:59
@luigifcruz
Copy link
Author

Actually, this will break the cursor position if the glfwGetMonitorContentScale is above one and the glfwGetFramebufferSize and glfwGetFramebufferSize are the same. Automatically resizing the canvas frame buffer size might be necessary. Or ignoring _emscripten_get_device_pixel_ratio() and using the ratio between native and normal dimensions as the scaling factor.

Input from the community here would be appreciated as both options have pros and cons.

@luigifcruz
Copy link
Author

Closed by #20584

@luigifcruz luigifcruz closed this Jan 6, 2024
@luigifcruz luigifcruz deleted the patch-1 branch January 6, 2024 20:26
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.

GLFW glfwGetFramebufferSize() and glfwGetWindowSize()
1 participant