- Pygame - Discussion
- Pygame - Useful Resources
- Pygame - Quick Guide
- Pygame - Errors and Exception
- Pygame - PyOpenGL
- Pygame - The Sprite Module
- Pygame - Access CDROM
- Pygame - Load cursor
- Pygame - Using Camera module
- Pygame - Playing Movie
- Pygame - Playing music
- Pygame - Mixer channels
- Pygame - Sound objects
- Pygame - Transforming Images
- Pygame - Use Text as Buttons
- Pygame - Moving Rectangular objects
- Pygame - Moving with mouse
- Pygame - Moving with Numeric pad keys
- Pygame - Moving an image
- Pygame - Displaying Text in Window
- Pygame - Loading image
- Pygame - Drawing shapes
- Pygame - Mouse events
- Pygame - Keyboard events
- Pygame - Event objects
- Pygame - Color object
- Pygame - Locals module
- Pygame - Display modes
- Pygame - Hello World
- Pygame - Overview
- Pygame - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
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 pst_modes().
>>> print (pygame.display.pst_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