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

Add support for enabling high DPI #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Fadenfire
Copy link

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
Author

Any news on this?

@ViRb3
Copy link
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
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
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.

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.

None yet

2 participants