renpy / pygame_sdl2

Reimplementation of portions of the pygame API using SDL2.
GNU Lesser General Public License v2.1
325 stars 63 forks source link

macOS Mojave / retina mac: Issue where windows are half size. #108

Closed aaronrudkin closed 1 month ago

aaronrudkin commented 5 years ago

Minimum non-working example:

import pygame_sdl2

pygame_sdl2.init()
pygame_sdl2.display.init()

# Make a window
test_window = pygame_sdl2.display.set_mode((500, 500))
test_window.fill((0, 0, 0))

# Colors
white = (255, 255, 255)
red = (255, 0, 0)
blue = (0, 0, 255)

# How big do you think the window is?
print(test_window.get_size())

done = 0

while not done:
        for event in pygame_sdl2.event.get():
            if event.type == pygame_sdl2.QUIT:
                done = 1

    # Draw a white rectangle on the upper-left quarter
    pygame_sdl2.draw.rect(test_window, white, (0, 0, 250, 250))
    # Draw a red rectangle on the lower-left quarter
    pygame_sdl2.draw.rect(test_window, red, (0, 250, 250, 250))
    # Draw a blue rectangle on the top-right quarter
    pygame_sdl2.draw.rect(test_window, blue, (250, 0, 250, 250))
    # Update display: entire display is red.
    pygame_sdl2.display.update()

Although the window believes itself to be 500x500, what is actually being displayed is a 250x250 window, and the coordinates visible on the visible canvas are from (0, 250) to (250, 500). If I suppress the red rectangle, I see a line of white pixels at the very top and nothing else (so presumably 250 is the first pixel row I see).

Hardware / software info:

It is unclear to me if this is an SDL2 issue, a retina mac issue, a mojave beta issue, or a pygame_sdl2 issue. I should say in full disclosure that regular pygame doesn't render at all for me on this computer, I just get a blank window, so it's possible it's an OS issue. I can't easily revert or test on another machine, so it's hard for me to say for sure. When I googled I found a number of people complaining about various retina mac issues with pygame years ago, but other than that nothing.

It'd be great to get confirmation from someone else using a Retina Mac on Mojave that it happens, or someone else using a Retina Mac on a non-Mojave OS to confirm it doesn't.