GTNewHorizons / lwjgl3ify

A mod to run Minecraft 1.7.10 using LWJGL3 and Java 17+
GNU Lesser General Public License v3.0
164 stars 33 forks source link

Fix scaling on HiDPI screens with Wayland #171

Closed JL2210 closed 2 weeks ago

JL2210 commented 1 month ago

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)

JL2210 commented 1 month ago

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.

JL2210 commented 1 month ago

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

JL2210 commented 1 month ago

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

JL2210 commented 1 month ago

Ready for review again