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

High DPI Support #589

Open
thejustinwalsh opened this issue Apr 10, 2019 · 3 comments · May be fixed by #921
Open

High DPI Support #589

thejustinwalsh opened this issue Apr 10, 2019 · 3 comments · May be fixed by #921

Comments

@thejustinwalsh
Copy link
Contributor

Requesting High DPI support.

Looks like all the work in the hashlink SDL plugin is already done to support passing the SDL_WINDOW_ALLOW_HIGHDPI flag at window creation time. Not sure what the required support would look like when using DirectX.

Would love to see the feature abstracted through heaps and any advice on best implementation is welcome as I can submit a PR to support it.

@thejustinwalsh
Copy link
Contributor Author

thejustinwalsh commented Apr 25, 2019

Notes:
On iOS you must do two things to get a high DPI rendering context.

  1. NSHighResolutionCapable = YES in Info.plist
  2. Pass in the SDL_WINDOW_ALLOW_HIGHDPI flag when creating the window by changing
    window = new sdl.Window(title, width, height);

    to (formatted to not wrap)
window = new sdl.Window(title, width, height, 
  sdl.Window.SDL_WINDOWPOS_CENTERED, sdl.Window.SDL_WINDOWPOS_CENTERED,
  sdl.Window.SDL_WINDOW_SHOWN | 
  sdl.Window.SDL_WINDOW_RESIZABLE | 
  sdl.Window.SDL_WINDOW_ALLOW_HIGHDPI
);

From what I can tell if you Omit the NSHighResolutionCapable flag or set it to NO in your Info.plist the additional SDL_WINDOW_ALLOW_HIGHDPI seems to have no effect. Although I am not certain at this time of how this flag affects all platforms. Also worth noting, the calls to hxd.System.width and hxd.System.height will return the size of the device screen in points and you would need to know the DPI of your screen to apply the appropriate scale from points to pixels when running in High DPI mode.

@ncannasse
Copy link
Member

In order to support this on SDL first, we would need to be able to query from SDL for the screen DPI, as described here https://nlguillemot.wordpress.com/2016/12/11/high-dpi-rendering/

This requires adding some new primitives to Hashlink/SDL support here:
https://github.com/HaxeFoundation/hashlink/tree/master/libs/sdl
and Haxe wrapper
https://github.com/HaxeFoundation/hashlink/tree/master/libs/sdl/sdl

Once this is done, I guess we could enable it with a define: -D highdpi and add the #if highdpi sections in the SDL Window support.

@AustinEast
Copy link

AustinEast commented Mar 4, 2020

Looks like this issue can be fixed if you use the latest version of SDL (beyond the latest release on homebrew). This is a quick fix that has worked for me and others:

  1. Grab a newer version of SDL and replace your current installation with it (this mirror works fine: https://github.com/spurious/SDL-mirror)
  2. Rebuild hashlink (with the normal make -> make install instructions)
  3. Rebuild your project and see the fixed display!

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 a pull request may close this issue.

3 participants