pygame2.sdl.video

The pygame2.sdl.video C API contains fundamental objects and functions for accessing and manipulating the screen display, image surface objects and overlay graphics.

Import

Include headers:

pygame2/pgsdl.h
int import_pygame2_sdl_video(void)
Imports the pygame2.sdl.video module. This returns 0 on success and -1 on failure.

Basic Types

SDLSurfaceLock

Internally used lock tracking object. It is used in conjunction with the PySDLSurface_AcquireLockObj() function to keep track of the external locking objects for a PySDLSurface.

PyObject* SDLSurfaceLock.surface

The PySDLSurface object that is locked.

PyObject* SDLSurfaceLock.lockobj

The PyObject that causes the lock on the PySDLSurface.

Macros

ASSERT_VIDEO_INIT(retval)
Checks, whether the video subsystem was properly initialised. If not, this will set a PyExc_PyGameError and return retval.
ASSERT_VIDEO_SURFACE_SET(retval)
Checks, whether a display surface was created already using pygame2.sdl.video.set_mode(). If not, this will set a PyExc_PyGameError and return retval.

Functions

int ColorFromObj(PyObject *obj, SDL_PixelFormat *format, Uint32 *val)
Converts the passed object to a 32-bit integer color value and stores the result in val. This returns 1 on success and 0 on failure.

PyPixelFormat

PyPixelFormat
PyPixelFormat_Type

The PyPixelFormat object is a wrapper around the SDL_PixelFormat type, which contains format information about surfaces, such as the bit depth, color mask, etc.

Members

SDL_PixelFormat* PyPixelFormat.format
The SDL_PixelFormat pointer to access the pixel format information.
int PyPixelFormat.readonly
A read-only flag that indicates whether the information of the underlying SDL_PixelFormat are allowed to be changed.

Functions

int PyPixelFormat_Check(PyObject *obj)
Returns true, if the argument is a PyPixelFormat or a subclass of PyPixelFormat.
PyObject* PyPixelFormat_New(void)
Creates a new, empty and writable PyPixelFormat object. On failure, this returns NULL.
PyObject* PyPixelFormat_NewFromSDLPixelFormat(SDL_PixelFormat *format)
Creates a new, read-only PyPixelFormat object from the passed SDL_PixelFormat. The passed format must not be freed during the lifetime of the PyPixelFormat object. On failure, this returns NULL.
SDL_PixelFormat* PyPixelFormat_AsPixelFormat(PyObject *obj)
Macro for accessing the format member of the PyPixelFormat. This does not perform any type or argument checks.

PySDLSurface

PySDLSurface
PySDLSurface_Type

The PySDLSurface is the most important object type for the pygame2.sdl.video module. It is used to hold information about the 2D pixel buffer information of any visible object for the pygame2.sdl modules.

The PySDLSurface class inherits from the PySurface class of the pygame2.base module.

Members

PySurface PySDLSurface.pysurface
The base class of the PySDLSurface.
SDL_Surface* PySDLSurface.surface
The SDL_Surface pointer to access the surface information.
PyObject* PySDLSurface.locklist
A list of external objects owning a lock on the surface. Never manipulate the list directly. Use the PySDLSurface_AddRefLock() and PySDLSurface_RemoveRefLock() functions instad to acquire or release an external lock
pguint16 PySDLSurface.intlocks
Counter of internally set locks on the surface. This value is usually incremented and decremented by the pygame2.sdl.video.Surface.lock() and pygame2.sdl.video.Surface.unlock() methods and should not manipulated directly.

Functions

SDL_Surface* PySDLSurface_AsSDLSurface(PyObject *obj)
Macro for accessing the surface member of the PySDLSurface. This does not perform any type checks.
PySurface* PySDLSurface_AsPySurface(PyObject *obj)
Macro for accessing the pysurface member of the PySDLSurface. This does not perform any type or argument checks.
int PySDLSurface_Check(PyObject *obj)
Returns true, if the argument is a PySDLSurface or a subclass of PySDLSurface.
PyObject* PySDLSurface_New(int width, int height)
Creates a new PySDLSurface with the specified width and height. On failure, this returns NULL.
PyObject* PySDLSurface_NewFromSDLSurface(SDL_Surface *surface)
Creates a new PySDLSurface from an existing SDL_Surface. The passed surface must not be freed during the lifetime of the PySDLSurface object. On failure, this returns NULL.
PyObject* PySDLSurface_Copy(PyObject *obj)
Creates an exact copy of the passed PySDLSurface. This creates a new PySDLSurface and copies the information of obj to it (except for the locks). On failure, this returns NULL.
int PySDLSurface_AddRefLock(PyObject *surface, PyObject *lockobj)
Adds a lock to the passed PySDLSurface, which will be hold by lockobj. This will not increase lockobj‘s refcount, but use weak references instead. If lockobj is garbage-collected any time later, the lock on the PySDLSurface will be removed automatically on the next invocation of PySDLSurface_RemoveRefLock(). This returns 1 on success and 0 on failure.
int PySDLSurface_RemoveRefLock(PyObject *surface, PyObject *lockobj)
Removes a lock from the passed PySDLSurface. lockobj denotes the object holding the lock. It also removes any other outstanding garbage-collected lock references. This returns 1 on success and 0 on failure.
PyObject* PySDLSurface_AcquireLockObj(PyObject *surface, PyObject *lockobj)
Acquires a PyCObject that keeps a lock on the passed PySDLSurface. lockobj denotes the object holding the lock. If the return value is garbage-collected, the lock on the PySDLSurface will be removed immediately.

PyOverlay

PyOverlay
PyOverlay_Type

PyOverlay is a low-level overlay graphics class for PySDLSurface objects. It support direct operations on the YUV overlay buffers of the graphics objects.

Members

SDL_Overlay* PyOverlay.overlay
The SDL_Overlay pointer to access the overlay information.
PyObject* PyOverlay.surface
The PySDLSurface the PyOverlay was created for.
PyObject* PyOverlay.locklist
A list of external objects owning a lock on the overlay. Never manipulate the list directly. Use the PyOverlay_AddRefLock() and PyOverlay_RemoveRefLock() functions instad to acquire or release an external lock

Functions

SDL_Overlay* PyOverlay_AsOverlay(PyObject *obj)
Macro for accessing the overlay member of the PyOverlay. This does not perform any type checks.
PyObject* PyOverlay_New(PyObject *obj, int width, int height, Uint32 format)

Creates a new PyOverlay for the passed PySDLSurface obj. width and height specify the width and height of the PyOverlay, which may or may not exceed the size of the PySDLSurface. The format argument specifies the YUV overlay type to use.

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

On failure, this returns NULL.

int PyOverlay_AddRefLock(PyObject *overlay, PyObject *lockobj)
Adds a lock to the passed PyOverlay, which will be hold by lockobj. This will not increase lockobj‘s refcount, but use weak references instead. If lockobj is garbage-collected any time later, the lock on the PyOverlay will be removed automatically on the next invocation of PyOverlay_RemoveRefLock(). This returns 1 on success and 0 on failure.
int PyOverlay_RemoveRefLock(PyObject *overlay, PyObject *lockobj)
Removes a lock from the passed PyOverlay. lockobj denotes the object holding the lock. It also removes any other outstanding garbage-collected lock references. This returns 1 on success and 0 on failure.

Table Of Contents

Previous topic

pygame2.sdl.mouse

Next topic

pygame2.sdl.rwops

This Page