arcade icon indicating copy to clipboard operation
arcade copied to clipboard

Advanced: Document how arcade handles hidpi (mouse and framebuffer)

Open pushfoo opened this issue 3 years ago • 6 comments

Documentation request:

What documentation needs to change?

We will eventually need a new page explaining different strategies for handling high dpi screens.

Where is it located?

Does not exist yet

What is wrong with it? How can it be improved?

#1147 appears rooted in a lack of such documentation. Einarf's comment on the issue may be a good start for building this out.

pushfoo avatar Mar 31 '22 20:03 pushfoo

High dpi is actually completely transparent for the user. It's not something they even have to think about.

einarf avatar Mar 31 '22 20:03 einarf

Including for pixel games? My memory of macOS was that things frequently got weird, but i don't have a working retina mac to verify at the moment

pushfoo avatar Mar 31 '22 20:03 pushfoo

Pyglet reports mouse positions in window coordinates for simplicity, so it's not going to be a problem here. We annotate them as ints and move on for now 😄

BUT ... it could acutally be a good idea to write a section a about high dpi stuff in advanced docs. It should include mouse coordinates and how we handle a window with pixel ratio != 1.0.

einarf avatar Mar 31 '22 20:03 einarf

Let's keep this issue. I changed the title.

einarf avatar Mar 31 '22 20:03 einarf

On Windows, I am using this ctypes hack on my main function:

# (...)

from os import name as os_name

def main():
    """Main function"""

    if os_name == "nt":  # Windows
        import ctypes

        ctypes.windll.shcore.SetProcessDpiAwareness(1)
        ctypes.windll.user32.SetProcessDPIAware()

    window = arcade.Window(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
    menu_view = MainMenu()
    window.show_view(menu_view)
    arcade.run()


if __name__ == "__main__":
    main()

I do the same in tkinter apps.

ffunenga avatar Dec 31 '22 12:12 ffunenga

On Windows, I am using this ctypes hack on my main function:

You might just PR that in pyglet? https://github.com/pyglet/pyglet/blob/9727b43a48fab6b5ca65f4a951bb87616aaadb12/pyglet/font/win32.py

einarf avatar Dec 31 '22 18:12 einarf