Skip to content

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

jefvel added 3 commits January 7, 2021 18:08
  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