Skip to content
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

Fix scaling on HiDPI screens with Wayland #171

Merged
merged 4 commits into from
Sep 13, 2024

Conversation

JL2210
Copy link
Contributor

@JL2210 JL2210 commented Aug 25, 2024

The game expects getWidth and getHeight to return framebuffer coordinates rather than screen-space coordinates (as shown by the calls to glViewport). This was broken on scaling factors greater than 1 but also masked by GL_SCALE_FRAMEBUFFER.

Additionally, the game's mouse code also expects framebuffer coordinates to be returned. This fixes that by converting to and from screen-space during calls to mouse code.

Disable GLFW_COCOA_RETINA_FRAMEBUFFER for now, it seems to not play nice on non-MacOS systems. At least for me it makes the title screen much larger than the window when playing in fullscreen.

Screenshot before the change:
image

Screenshot after the change:
image

Before is marginally fuzzier (and obviously doesn't work with the title screen)

The game expects getWidth and getHeight to return framebuffer
coordinates rather than screen-space coordinates (as shown by the
calls to glViewport). This was broken on scaling factors greater
than 1 but also masked by GL_SCALE_FRAMEBUFFER.

Additionally, the game's mouse code *also* expects framebuffer
coordinates to be returned. This fixes that by converting to and
from screen-space during calls to mouse code.

Disable GLFW_COCOA_RETINA_FRAMEBUFFER for now, it seems to not
play nice on non-MacOS systems. At least for me it makes the title
screen larger than the window when playing in fullscreen
I think their framebuffer implementation is buggy? I don't really
want to touch this since I don't have a Mac to test on

I think their GPUs are weak anyways and probably can't handle
rendering GTNH at 260 DPI or whatever Retina does
@JL2210 JL2210 marked this pull request as draft August 25, 2024 06:36
@JL2210
Copy link
Contributor Author

JL2210 commented Aug 25, 2024

Decided to mark this as a draft until it can be tested on Mac/with controllers/etc

I think I also need to put in a fix to properly set the window size. Right now it's setting the window size rather than the framebuffer size, I think the intended behavior is to set the framebuffer -- EDIT -- upon further inspection, it appears this behavior matches that of modern vanilla, even if not matching up perfectly with X. At worst it's a minor annoyance, so I'll leave it be.

kappa-maintainer added a commit to CleanroomMC/Cleanroom that referenced this pull request Aug 26, 2024
@JL2210 JL2210 marked this pull request as ready for review August 28, 2024 17:36
@JL2210
Copy link
Contributor Author

JL2210 commented Aug 28, 2024

Tested and appears to work as normal on Mac. Definitely improved Linux experience.

@Dream-Master Dream-Master requested a review from a team August 28, 2024 17:54
@JL2210
Copy link
Contributor Author

JL2210 commented Sep 1, 2024

I think there might be a bug in the implementation of getPixelScaleFactor on x11 and Windows, please don't merge

@JL2210 JL2210 marked this pull request as draft September 1, 2024 18:13
Previous implementation was broken on hidpi platforms where the
size of the framebuffer and the size of the window correlate 1:1.
This manifested in the mouse code thinking the mouse was in a
different location than it actually was.

New implementation explicitly calculates the ratio between the
framebuffer size and the window size, rather than relying on
glfwGetWindowContentScale.

Remove GLFW_SCALE_FRAMEBUFFER/GLFW_COCOA_RETINA_FRAMEBUFFER,
it appears that it is not needed.
@JL2210 JL2210 marked this pull request as ready for review September 1, 2024 18:28
@JL2210
Copy link
Contributor Author

JL2210 commented Sep 1, 2024

Ready for review again

@eigenraven eigenraven merged commit bff0296 into GTNewHorizons:master Sep 13, 2024
1 check 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