Pygame – Display modes


Pygame – Display Modes



”;


As in the above example, a display surface is created by set_mode() function defined in pygame.display module.


pygame.display.set_mode(size, flags, depth, display, vsync)

The size parameter is a tuple of width and height in pixels. If size is not set, the surface will have the size of current resolution.

The flags parameter controls the type of display represented by following predefined constants −











pygame.FULLSCREEN create a fullscreen display
pygame.DOUBLEBUF recommended for HWSURFACE or OPENGL
pygame.HWSURFACE hardware accelerated, only in FULLSCREEN
pygame.OPENGL create an OpenGL-renderable display
pygame.RESIZABLE display window should be sizeable
pygame.NOFRAME display window will have no border or controls
pygame.SCALED resolution depends on desktop size and scale graphics
pygame.SHOWN window is opened in visible mode (default)
pygame.HIDDEN window is opened in hidden mode

If the vsync parameter is set to 1, it is possible to get a display with vertical sync, but you are not guaranteed to get one. The request only works at all for calls to set_mode() with the pygame.OPENGL or pygame.SCALED flags set.

The display index 0 means the default display is used. Depth parameter will default to the best and fastest color depth for the system. For given width and height, Pygame will choose best mode available from list_modes().


>>> print (pygame.display.list_modes())
[(1366, 768), (1360, 768), (1280, 768), (1280, 720), (1024, 768), (800, 600), (640, 480)]

pygame.display.mode_ok()

This function Pick the best color depth for a display mode. It is used to determine if a requested display mode is available. It will return 0 if the display mode cannot be set. Otherwise it will return a pixel depth that best matches the display asked for.

pygame.display.update()

This function will update the contents of the entire display.

Advertisements

”;

Leave a Reply

Your email address will not be published. Required fields are marked *