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 docs for windows DPI awareness hint #2511

Merged
merged 1 commit into from
Oct 9, 2023
Merged

Conversation

MyreMylar
Copy link
Member

After a bit of back and forth in #2081 the best solution seemed to be to document the current behaviour of DPI awareness on windows and revisit this topic in the SDL 3 switchover. Currently in SDL2 DPI awareness is a bit of a mess with different behaviour on different platforms and different APIs in SDL 2.

@MyreMylar MyreMylar requested a review from a team as a code owner October 8, 2023 16:52
@MyreMylar
Copy link
Member Author

This is my little test program to play around with DPI in SDL2:

import pygame
import os
import platform

from pygame._sdl2.window import Window


if platform.uname().system == "Windows":
    build_num = int(platform.uname().version.split(".")[2])
    if build_num > 14393:
        os.environ["SDL_WINDOWS_DPI_AWARENESS"] = "permonitorv2"
    elif build_num > 9600:
        os.environ["SDL_WINDOWS_DPI_AWARENESS"] = "permonitor"
    else:
        os.environ["SDL_WINDOWS_DPI_AWARENESS"] = "system"


pygame.init()

window = Window(allow_high_dpi=True)

running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

Copy link
Member

@Temmie3754 Temmie3754 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suitably covers how to easily implement DPI awareness in pygame on windows and other platforms.

Copy link
Member

@ankith26 ankith26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the PR 🎉

@ankith26 ankith26 added this to the 2.4.0 milestone Oct 9, 2023
@ankith26 ankith26 merged commit 3c313a9 into main Oct 9, 2023
@ankith26 ankith26 deleted the fix-dpi-aware-fullscreen branch October 9, 2023 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants