pygame2.sdl.constants – Constants for SDL

This module contains the constants used throughout the pygame2.sdl modules.

Initialisation Constants

Those constants are used by the pygame2.sdl.init(), pygame2.sdl.init_subsystem() and pygame2.sdl.quit_subsystem() functions.

pygame2.sdl.constants.INIT_AUDIO
Initialises the SDL audio subsystem.
pygame2.sdl.constants.INIT_CDROM
Initialises the SDL cdrom subsystem.
pygame2.sdl.constants.INIT_TIMER
Initialises the SDL timer subsystem.
pygame2.sdl.constants.INIT_JOYSTICK
Initialises the SDL joystick subsystem.
pygame2.sdl.constants.INIT_VIDEO
Initialises the SDL video subsystem.
pygame2.sdl.constants.INIT_EVERYTHING
Initialises all parts of the SDL subsystems.
pygame2.sdl.constants.INIT_NOPARACHUTE
Initialises the SDL subsystems without a segmentation fault parachute.
pygame2.sdl.constants.INIT_EVENTTHREAD
Initialises the SDL event subsystem with threading support.

Blending Constants

Those constants are used by the pygame2.sdl.video.Surface.blit() and pygame2.sdl.video.Surface.fill() methods.

If not stated otherwise, each of the modes will work on a per-channel basis, so that the described operation is performed on each RGB(A) color component. This means that e.g. BLEND_RGB_ADD performs some operation similar to (R1 + R1, G1 + G2, B1 + B2).

pygame2.sdl.constants.BLEND_RGB_ADD
Used for an additive blend, ignoring the per-pixel alpha value. The sum of the both RGB values will used for the result.
pygame2.sdl.constants.BLEND_RGB_SUB
Used for an subtractive blend, ignoring the per-pixel alpha value. The difference of both RGB values will be used for the result. If the difference is smaller than 0, it will be set to 0.
pygame2.sdl.constants.BLEND_RGB_MULT
Used for an multiply blend, ignoring the per-pixel alpha value. The both RGB values will be multiplied with each other, causing the result to be darker.
pygame2.sdl.constants.BLEND_RGB_AND
Used for a binary AND’d blend, ignoring the per-pixel alpha value. The bitwise AND combination of both RGB values will be used for the result.
pygame2.sdl.constants.BLEND_RGB_OR
Used for a binary OR’d blend, ignoring the per-pixel alpha value. The bitwise OR combination of both RGB values will be used for the result.
pygame2.sdl.constants.BLEND_RGB_XOR
Used for a binary XOR’d blend, ignoring the per-pixel alpha value. The bitwise XOR combination of both RGB values will be used for the result.
pygame2.sdl.constants.BLEND_RGB_MIN
Used for a minimum blend, ignoring the per-pixel alpha value. The minimum of both RGB values will be used for the result.
pygame2.sdl.constants.BLEND_RGB_MAX
Used for a maximum blend, ignoring the per-pixel alpha value. The maximum of both RGB values will be used for the result.
pygame2.sdl.constants.BLEND_RGB_AVG
Used for an average blend, ignoring the per-pixel alpha value. The average of an addition of both RGB values will be used for the result.
pygame2.sdl.constants.BLEND_RGB_DIFF
Used for a difference blend, ignoring the per-pixel alpha value. The real difference of both RGB values will be used for the result.
pygame2.sdl.constants.BLEND_RGB_SCREEN
Used for a screen blend, ignoring the per-pixel alpha value. The inverted multiplication result of the inverted RGB values will be used, causing the result to be brighter.
pygame2.sdl.constants.BLEND_RGBA_ADD
Used for an additive blend, with the per-pixel alpha value. The sum of the both RGBA values will used for the result.
pygame2.sdl.constants.BLEND_RGBA_SUB
Used for an subtractive blend, with the per-pixel alpha value. The difference of both RGBA values will be used for the result. If the difference is smaller than 0, it will be set to 0.
pygame2.sdl.constants.BLEND_RGBA_MULT
Used for an multiply blend, with the per-pixel alpha value. The both RGBA values will be multiplied with each other, causing the result to be darker.
pygame2.sdl.constants.BLEND_RGBA_AND
Used for a binary AND’d blend, with the per-pixel alpha value. The bitwise AND combination of both RGBA values will be used for the result.
pygame2.sdl.constants.BLEND_RGBA_OR
Used for a binary OR’d blend, with the per-pixel alpha value. The bitwise OR combination of both RGBA values will be used for the result.
pygame2.sdl.constants.BLEND_RGBA_XOR
Used for a binary XOR’d blend, with the per-pixel alpha value. The bitwise XOR combination of both RGBA values will be used for the result.
pygame2.sdl.constants.BLEND_RGBA_MIN
Used for a minimum blend, with the per-pixel alpha value. The minimum of both RGBA values will be used for the result.
pygame2.sdl.constants.BLEND_RGBA_MAX
Used for a maximum blend, with the per-pixel alpha value. The maximum of both RGBA values will be used for the result.
pygame2.sdl.constants.BLEND_RGBA_AVG
Used for an average blend, with the per-pixel alpha value. The average of an addition of both RGBA values will be used for the result.
pygame2.sdl.constants.BLEND_RGBA_DIFF
Used for a difference blend, with the per-pixel alpha value. The real difference of both RGBA values will be used for the result.
pygame2.sdl.constants.BLEND_RGBA_SCREEN
Used for a screen blend, with the per-pixel alpha value. The inverted multiplication result of the inverted RGBA values will be used, causing the result to be brighter.

CD-ROM Constants

The following constants are used by the pygame2.sdl.cdrom module.

pygame2.sdl.constants.MAX_TRACKS
The maximum amount of tracks to manage on a CD-ROM.

The following constants are used by the pygame2.sdl.cdrom.CDTrack.type attribute.

pygame2.sdl.constants.AUDIO_TRACK
Indicates an audio track.
pygame2.sdl.constants.DATA_TRACK
Indicates a data track.

The following constants are used by the pygame2.sdl.cdrom.CD.status attribute:

pygame2.sdl.constants.CD_TRAYEMPTY
Indicates that no CD-ROM is in the tray.
pygame2.sdl.constants.CD_STOPPED
Indicates that the CD playback has been stopped.
pygame2.sdl.constants.CD_PLAYING
Indicates that the CD is currently playing a track.
pygame2.sdl.constants.CD_PAUSED
Indicates that the CD playback has been paused.
pygame2.sdl.constants.CD_ERROR
Indicates an error on accessing the CD.

Event Constants

Those constants are used by the pygame2.sdl.event module functions.

pygame2.sdl.constants.NOEVENT
Indicates no event.
pygame2.sdl.constants.NUMEVENTS
The maximum amount of event types allowed to be used.
pygame2.sdl.constants.ACTIVEEVENT
Raised, when the SDL application state changes.
pygame2.sdl.constants.KEYDOWN
Raised, when a key is pressed down.
pygame2.sdl.constants.KEYUP
Raised, when a key is released.
pygame2.sdl.constants.MOUSEMOTION
Raised, when the mouse moves.
pygame2.sdl.constants.MOUSEBUTTONDOWN
Raised, when a mouse button is pressed down.
pygame2.sdl.constants.MOUSEBUTTONUP
Raised, when a mouse button is released.
pygame2.sdl.constants.JOYAXISMOTION
Raised, when a joystick axis moves.
pygame2.sdl.constants.JOYBALLMOTION
Raised, when a trackball on a joystick moves.
pygame2.sdl.constants.JOYHATMOTION
Raised, when a hat on a joystick moves.
pygame2.sdl.constants.JOYBUTTONDOWN
Raised, when a joystick button is pressed down.
pygame2.sdl.constants.JOYBUTTONUP
Raised, when a joystick button is released.
pygame2.sdl.constants.QUIT
Raised, when the SDL application window shall be closed.
pygame2.sdl.constants.SYSWMEVENT
Raised, when an unknown, window manager specific event occurs.
pygame2.sdl.constants.VIDEORESIZE
Raised, when the SDL application window shall be resized.
pygame2.sdl.constants.VIDEOEXPOSE
Raised, when the screen has been modified outside of the SDL application and the SDL application window needs to be redrawn.
pygame2.sdl.constants.USEREVENT
Raised, when a user-specific event occurs.

Application Constants

Those constants are used by the ACTIVEEVENT event and the pygame2.sdl.event.get_app_state() method.

pygame2.sdl.constants.APPACTIVE
Indicates that that the SDL application is currently active.
pygame2.sdl.constants.APPINPUTFOCUS
Indicates that the SDL application has the keyboard input focus.
pygame2.sdl.constants.APPMOUSEFOCUS
Indicates that the SDL application has the mouse input focus.

Keyboard Constants

The following constants are used by the pygame2.sdl.keyboard.set_repeat() function:

pygame2.sdl.constants.DEFAULT_REPEAT_DELAY
The default delay before starting to repeat raising KEYDOWN event on pressing a key down.
pygame2.sdl.constants.DEFAULT_REPEAT_INTERVAL
The default interval for raising KEYDOWN events on pressing a key down.

The following constants are used by the pygame2.sdl.keyboard.get_state() and pygame2.sdl.keyboard.get_key_name() functions and the KEYDOWN and KEYUP events.

Constant Meaning and Value
K_UNKNOWN An unknown key.
K_a - K_z Alphabetical keys ranging from a to z. There is no captalised version of them. Instead the keyboard modifier state can be checked for KMOD_SHIFT being set.
K_0 - K_9 Numerical keys ranging from 0 to 9. Those differ from the numerical keys on the keypad.
K_TAB, K_SPACE, K_EXCLAIM, K_HASH, K_QUOTEDBL, K_DOLLAR, K_QUOTE, K_AMPERSAND, K_LEFTPAREN, K_RIGHTPAREN, K_ASTERISK, K_PLUS, K_MINUS, K_COMMA, K_PERIOD, K_SLASH, K_BACKSLASH, K_COLON, K_SEMICOLON, K_QUESTION, K_AT, K_LEFTBRACKET, K_RIGHTBRACKET, K_CARET, K_UNDERSCORE, K_BACKQUOTE Tabulator, Space, Exclamation Mark, Hash, Double Quote, Dollar sign, Single Quote, Ampersand, Left and Right Parenthesis, Asterisk, Plus and Minus, Comma, Period, Slash and Backslash, Colon and Semicolon, Question Mark, At sign, Left and Right Bracket, Caret, Underscore and Backquote keys.
K_LESS, K_GREATER, K_EQUALS Less, Greater and Equality sign keys.
K_F1 - K_F15 Function keys from F1 to F15.
K_HOME, K_END, K_INSERT, K_DELETE, K_PAGEUP, K_PAGEDOWN, K_BACKSPACE Home and End, Insert and Delete, PageUp and PageDown and Backspace keys.
K_LEFT, K_RIGHT, K_DOWN, K_UP Cursor keys.
K_KP0 - K_KP9 Numerical keys on the keypad, ranging from 0 to 9.
K_KP_PERIOD, K_KP_DIVIDE, K_KP_MULTIPLY, K_KP_MINUS, K_KP_PLUS, K_KP_EQUALS, K_KP_ENTER Period, Divide, Multiply, Plus, Minus, Equal sign and the Enter key on the keypad.
K_HELP, K_PRINT, K_SYSREQ, K_BREAK, K_MENU, K_POWER, K_EURO, K_FIRST, K_LAST Help, Print, SysReq, Break, Menu, Power, Euro sign, First and Last keys.
K_ESCAPE, K_PAUSE, K_CLEAR Escape, Pause and Clear keys.
K_NUMLOCK, K_CAPSLOCK, K_SCROLLOCK NumLock, CapsLock and ScrolLock keys.
K_RSHIFT, K_LSHIFT, K_RCTRL, K_LCTRL, K_RALT, K_LALT, K_RMETA, K_LMETA, K_LSUPER, K_RSUPER, K_MODE Right and Left Shift, Right and Left Control, Right and Left Alternative, Right and Left Meta, Right and Left Super and Mode keys.

The following constants are keyboard modifer states, used as bitwise combinations to check, whether they were hold down on keyboard input. They are used by the pygame2.sdl.keyboard.get_mod_state() and pygame2.sdl.keyboard.set_mod_state() functions.

Constant Meaning and Value
KMOD_NONE No modifier key was pressed.
KMOD_LSHIFT, KMOD_RSHIFT, KMOD_SHIFT Left Shift, Right Shift or one of both was pressed.
KMOD_LCTRL, KMOD_RCTRL, KMOD_CTRL Left Control, Right Contro or one of both was pressed.
KMOD_LALT, KMOD_RALT, KMOD_ALT Left Alternative, Right Alternative or one of both was pressed.
KMOD_LMETA, KMOD_RMETA, KMOD_META Left Meta, Right Met or one of both was pressed.
KMOD_NUM, KMOD_CAPS, KMOD_MODE NumLock, CapsLock or Mode was pressed.

Overlay Types

The pygame2.sdl.video.Overlay class supports the following video overlay types.

pygame2.sdl.constants.YV12_OVERLAY
Planar mode: Y + V + U
pygame2.sdl.constants.IYUV_OVERLAY
Planar mode: Y + U + V
pygame2.sdl.constants.YUY2_OVERLAY
Packed mode: Y0 + U0 + Y1 + V0
pygame2.sdl.constants.UYVY_OVERLAY
Packed mode: U0 + Y0 + V0 + Y1
pygame2.sdl.constants.YVYU_OVERLAY
Packed mode: Y0 + V0 + Y1 + U0

Surface Flags

The flags explained below are used by the pygame2.sdl.video.Surface class and various pygame2.sdl.video functions. Not all of them are however used or applicable to both, the module functions and the class itself. Using them, although not supported by the one or other, will not result in an error, instead the inappropriate flags are silently ignored.

pygame2.sdl.constants.SWSURFACE
The surface is held in system memory.
pygame2.sdl.constants.HWSURFACE
The surface is held in video memory.
pygame2.sdl.constants.PREALLOC
The surface uses preallocated memory.
pygame2.sdl.constants.SRCCOLORKEY
This flag turns on colorkeying for blits from this surface. If HWSURFACE is also specified and colorkeyed blits are hardware-accelerated, then SDL will attempt to place the surface in video memory. Use pygame2.sdl.video.Surface.set_colorkey() to set or clear this flag after surface creation.
pygame2.sdl.constants.SRCALPHA
This flag turns on alpha-blending for blits from this surface. If HWSURFACE is also specified and alpha-blending blits are hardware-accelerated, then the surface will be placed in video memory if possible. Use pygame2.sdl.video.Surface.set_alpha() to set or clear this flag after surface creation.
pygame2.sdl.constants.ASYNCBLIT

Enables the use of asynchronous updates of the surface. This will usually slow down blitting on single CPU machines, but may provide a speedincrease on SMP systems.

This is only available for the pygame2.sdl.video functions and the display surface set by pygame2.sdl.video.set_mode().

pygame2.sdl.constants.ANYFORMAT

Normally, if a video surface of the requested bits-per-pixel (bpp) is not available, SDL will emulate one with a shadow surface. Passing ANYFORMAT prevents this and causes SDL to use the video surface, regardless of its pixel depth.

This is only available for the pygame2.sdl.video functions and the display surface set by pygame2.sdl.video.set_mode().

pygame2.sdl.constants.HWPALETTE
Give SDL exclusive palette access. Without this flag you may not always get the colors you request with pygame2.sdl.video.Surface.set_colors() or pygame2.sdl.video.Surface.set_palette().
pygame2.sdl.constants.DOUBLEBUF

Enable hardware double buffering; only valid with HWSURFACE. Calling pygame2.sdl.video.Surface.flip() will flip the buffers and update the screen. All drawing will take place on the surface that is not displayed at the moment. If double buffering could not be enabled then pygame2.sdl.video.Surface.flip() will just perform a pygame2.sdl.video.Surface.update() on the entire screen.

This is only available for the pygame2.sdl.video functions and the display surface set by pygame2.sdl.video.set_mode().

pygame2.sdl.constants.FULLSCREEN

SDL will attempt to use a fullscreen mode. If a hardware resolution change is not possible (for whatever reason), the next higher resolution will be used and the display window centered on a black background.

This is only available for the pygame2.sdl.video functions and the display surface set by pygame2.sdl.video.set_mode().

pygame2.sdl.constants.OPENGL

Create an OpenGL rendering context. You should have previously set OpenGL video attributes with pygame2.sdl.gl.set_attribute().

This is only available for the pygame2.sdl.video functions and the display surface set by pygame2.sdl.video.set_mode().

pygame2.sdl.constants.OPENGLBLIT

Create an OpenGL rendering context, like above, but allow normal blitting operations. The screen (2D) surface may have an alpha channel, and pygame2.sdl.video.Surface.update() must be used for updating changes to the screen surface.

Note

This option is kept for compatibility only, and is not recommended for new code.

This is only available for the pygame2.sdl.video functions and the display surface set by pygame2.sdl.video.set_mode().

pygame2.sdl.constants.HWACCEL
Surface blits uses hardware acceleration.
pygame2.sdl.constants.RLEACCEL
Colorkey blitting is accelerated with RLE.
pygame2.sdl.constants.RESIZABLE

Create a resizable window. When the window is resized by the user a VIDEORESIZE event is generated and pygame2.sdl.video.set_mode() can be called again with the new size.

This is only available for the pygame2.sdl.video functions and the display surface set by pygame2.sdl.video.set_mode().

pygame2.sdl.constants.NOFRAME

If possible, NOFRAME causes SDL to create a window with no title bar or frame decoration. Fullscreen modes automatically have this flag set.

This is only available for the pygame2.sdl.video functions and the display surface set by pygame2.sdl.video.set_mode().

Various Constants

pygame2.sdl.constants.BYTEORDER
The byteorder, SDL and pygame2.sdl were compiled with. It is set to either LIL_ENDIAN or BIG_ENDIAN.
pygame2.sdl.constants.LIL_ENDIAN
Indicates a little endian byte order.
pygame2.sdl.constants.BIG_ENDIAN
Indicates a big endian byte order.