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

Added highDPI flag that enables it when creating a SDL window. #921

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

Conversation

jefvel
Copy link
Contributor

@jefvel jefvel commented Jan 7, 2021

I added a define -D highDPI, that will enable it when creating a SDL window.
It will then get the raw pixel size of the screen instead of window size, using SDL_GL_GetDrawableSize, and set the render context dimension to that when the window is resized.

I don't know if this is the correct way to do it, but to me it seems to work quite well.

High DPI flag off:

image

High DPI flag on:
image

Fixes #589, requires HaxeFoundation/hashlink#435 to be merged too

  The window size will be the same as a non high DPI one, but the underlying
  window buffer will be set to the correct pixel size, based on
  SDL_GL_GetDrawableSize instead of SDL_GetWindowSize.
@ncannasse
Copy link
Member

There's several places where we're using window.width, so I think that for HDPI the window get_width/get_height should return the actual inner pixels of the window (in hdpi mode). and mouseX/Y , resize() and mouse events should also work based on that.

This way one application will not have to change anything to go from LDPI to HDPI.

@jefvel
Copy link
Contributor Author

jefvel commented Jan 14, 2021

I'm not completely sure how to handle window resizes in that mode. If high DPI is enabled, and the window size is set in pixes, it will appear a quarter of the size of a non high DPI window.
Should this be handled manually by the developer by checking the windowToPIxelRatio variable, and then multiply the initial resolution by that?

@ncannasse
Copy link
Member

Yes I think it should be handled manually wrt the initial size, as in HDPI a window of 800x600 is really smaller

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.

High DPI Support
2 participants