pythonpython-3.xpygamedisplay

Reading pygame display's current flags (FULLSCREEN etc.)


Is it possible to read the current flags that the display has been given? So when one calls pygame.display.set_mode(resolution, FLAGS), I'd love to read them afterwards.

For example I'd like to have an is_fullscreen() function.


Solution

  • You're looking for the pygame.Surface.get_flags method.

    Returns a set of current Surface features. Each feature is a bit in the flags bitmask.

    pygame.display.set_mode returns a pygame.Surface. So call the get_flags method of your display and bitwise AND it with the specific flag.

    def is_fullscreen(display):
        return bool(display.get_flags() & pygame.FULLSCREEN)