Skip to content

Add support for enabling high DPI#1

Open
Fadenfire wants to merge 2 commits intoMinecraftMachina:masterfrom
Fadenfire:highdpi-fix
Open

Add support for enabling high DPI#1
Fadenfire wants to merge 2 commits intoMinecraftMachina:masterfrom
Fadenfire:highdpi-fix

Conversation

@Fadenfire
Copy link
Copy Markdown

I am currently working on a mod that allows Minecraft versions prior to 1.13 to take advantage of high DPI screens on macOS. To accomplish this I am setting the org.lwjgl.opengl.Display.enableHighDPI property to true on startup and then injecting calls to Display.getPixelScaleFactor() into Minecraft's code to scale the GUI properly. This works fine when using Mojang's LWJGL 2 libraries with x86_64 java, but when using the binaries provided by this repository with aarch64 java my mod ceases to work. The Minecraft window will only display the bottom left corner of the framebuffer.

After some research, I figured out that this is caused by eed74ff. I assume that this change was made to fix the issue with macOS defaulting to a high DPI framebuffer (I discovered that issue when I reverted this commit to see what would happen). That change is fine for normal Minecraft, because it doesn't make use of LWJGL 2's high DPI mode, but it prevents my mod from working.

This PR changes that line so that instead of always setting setWantsBestResolutionOpenGLSurface to NO, it'll set it to YES if high DPI mode is enabled and NO if it isn't. This should fix my issue while maintaining compatibility with everyone else. Let me know if you see any problems with my solution.

@Fadenfire
Copy link
Copy Markdown
Author

Any news on this?

@ViRb3
Copy link
Copy Markdown
Member

ViRb3 commented Apr 3, 2024

Hey @Fadenfire, really sorry for not responding before, it seems like GitHub disables notifications for forks (like this repo), so I never got any notification about your PR. I just stumbled on it now by accident.

@ViRb3
Copy link
Copy Markdown
Member

ViRb3 commented Apr 3, 2024

Looking at the existing behavior, we have:

enableHighDPI = LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 7) && parent == null &&
(Display.getPrivilegedBoolean("org.lwjgl.opengl.Display.enableHighDPI") || fullscreen);

With your proposed change, it seems like the DPI code will activate for fullscreen on vanilla Minecraft. What will be the side effects from that?

@Fadenfire
Copy link
Copy Markdown
Author

Thanks for catching that, I didn't see that enableHighDPI is enabled when fullscreen. Without making any changes on the Java side of things, I think it's probably best to only enable setWantsBestResolutionOpenGLSurface when enableHighDPI is true and we're not in fullscreen. This should keep the default behavior with vanilla minecraft.

@Wyvest
Copy link
Copy Markdown

Wyvest commented Jan 10, 2025

Any updates on this? This currently breaks something similar I am trying

@Aces-and-Jacks
Copy link
Copy Markdown

Aces-and-Jacks commented Mar 23, 2025

@ViRb3 Since you mentioned you don't get notifications for forks and it's been 2 years, do you still plan to merge this?

thecatcore pushed a commit to Legacy-Fabric/lwjgl that referenced this pull request Jul 2, 2025
thecatcore pushed a commit to Legacy-Fabric/lwjgl that referenced this pull request Sep 26, 2025
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.

4 participants