Flags and Depth in Coding (Pygame)
Asked Answered
C

1

5

So I am starting to learn pygame and in this line:

pygame.display.set_mode((640,300), 0, 32)

I'm wondering what does the 0, and 32 mean, and how will the program change if I change these two variables.

Comras answered 30/10, 2013 at 23:19 Comment(0)
M
7

From the documentation:

The flags argument is a collection of additional options. The depth argument represents the number of bits to use for color.

In this case, 0 means "don't set any flags." The available flags are:

   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

If you wanted to, say, have an OpenGL-renderable fullscreen surface, you'd set flags to pygame.FULLSCREEN | pygame.OPENGL -- OR-ing them together to get the right flag value.

The 32 is the color depth, in bits, of your display surface.

Machellemachete answered 30/10, 2013 at 23:22 Comment(2)
So if I wanted a flag I would say: pygame.display.set_mode((640,300), pygame.fullscreen, 32) ?Comras
pygame.display.set_mode((640,300), pygame.FULLSCREEN | pygame.OPENGL | pygame.NOFRAME, 32), for example.Machellemachete

© 2022 - 2024 — McMap. All rights reserved.