pygame-community / pygame-ce

🐍🎮 pygame - Community Edition is a FOSS Python library for multimedia applications (like games). Built on top of the excellent SDL library.
https://pyga.me
780 stars 123 forks source link

SCALED flag does not scale mouse pos with OPENGL flag #1902

Open VantaTree opened 1 year ago

VantaTree commented 1 year ago

Windows 11 SDL 2.0.22 Python 3.11.2 pygame-ce==2.1.3

pygame.init()
screen = pygame.display.set_mode((400,400), pygame.SCALED|pygame.OPENGL|pygame.DOUBLEBUF)

while True:

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            raise SystemExit
        if event.type == pygame.MOUSEMOTION:
            print(event.rel, event.pos)

    pygame.display.flip()

In the above example, the mouse pos isn't between (0, 0) and (400, 400). It's much Higher (815, 815). and (1535, 863) with FULLSCREEN flag.

pmp-p commented 1 year ago

Thhat could be an internal SDL problem or missing setting when using GL/GLES contexts, i have the exact same problem in Harfang3D which displays scaled and uses mouse from SDL2 (eg when used on wasm)

pmp-p commented 11 months ago

From a working Harfang fix ( handling mouse x/y ratio changes manually) : it seems that scaling event are not dispatched to SDL mouse handling code and it stays using original framebuffer size. Or maybe the SDL mouse handling code just ignore window viewport and size.