libretro.api.video.frame

Pixel format and software framebuffer types.

Corresponds to the retro_pixel_format and retro_framebuffer types in libretro.h.

Module Attributes

retro_video_refresh_t

Render a single video frame.

Classes

MemoryAccess

Flags describing allowed memory access for a framebuffer.

MemoryType

Flags describing the type of memory behind a framebuffer.

PixelFormat

Pixel format for video output.

retro_framebuffer

Corresponds to retro_framebuffer in libretro.h.

retro_video_refresh_t

Render a single video frame.

Registered by the frontend and called by the core once per retro_run() to deliver a frame of pixel data. Passing None (or the value of HW_FRAME_BUFFER_VALID for hardware rendering) for data indicates that the frontend should reuse the previous frame.

Parameters:
  • data – A c_void_ptr to the framebuffer. The pixel format is the one most recently set with RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, defaulting to PixelFormat.RGB1555.

  • width – Width of the frame, in pixels.

  • height – Height of the frame, in pixels.

  • pitch – Length of one row in data, in bytes.

Note

For best performance the framebuffer should be packed (i.e. pitch == width * bytes_per_pixel).

Corresponds to retro_video_refresh_t in libretro.h.

class PixelFormat[source]

Bases: IntEnum

Pixel format for video output.

Corresponds to retro_pixel_format in libretro.h.

>>> from libretro.api.video import PixelFormat
>>> PixelFormat.XRGB8888.bytes_per_pixel
4
RGB1555 = 0
XRGB8888 = 1
RGB565 = 2
property bytes_per_pixel

Size of a single pixel in this format, in bytes.

property pixel_typecode

Typecode for this pixel format, suitable for use with array or struct.

property pillow_mode

PIL-compatible mode string for this pixel format.

__new__(value)
classmethod value in self

Return True if value is in cls.

value is in cls if: 1) value is a member of cls, or 2) value is the value of one of the cls’s members. 3) value is a pseudo-member (flags)

classmethod self[name]

Return the member matching name.

__init__()
classmethod iter(self)

Return members in definition order.

classmethod len(self)

Return the number of members (no aliases)

class MemoryAccess[source]

Bases: IntFlag

Flags describing allowed memory access for a framebuffer.

Corresponds to the RETRO_MEMORY_ACCESS_* constants in libretro.h.

NONE = 0
WRITE = 1
READ = 2
__new__(value)
other in self

Returns True if self has at least the same flags set as other.

iter(self)

Returns flags in definition order.

len(self)

Return the number of members (no aliases)

classmethod self[name]

Return the member matching name.

__init__()
class MemoryType[source]

Bases: IntFlag

Flags describing the type of memory behind a framebuffer.

Corresponds to the RETRO_MEMORY_TYPE_* constants in libretro.h.

NONE = 0
CACHED = 1
__new__(value)
other in self

Returns True if self has at least the same flags set as other.

iter(self)

Returns flags in definition order.

len(self)

Return the number of members (no aliases)

classmethod self[name]

Return the member matching name.

__init__()
class retro_framebuffer[source]

Bases: Structure

Corresponds to retro_framebuffer in libretro.h.

Describes a framebuffer obtained from the frontend.

>>> from libretro.api.video import retro_framebuffer
>>> fb = retro_framebuffer()
>>> fb.data is None
True
data

Pointer to the framebuffer’s pixel data.

width

Width of the framebuffer in pixels.

height

Height of the framebuffer in pixels.

pitch

Number of bytes per row.

format

Pixel format of the framebuffer.

__init__(*args, **kwargs)
classmethod __new__(*args, **kwargs)
access_flags

Allowed memory access flags.

memory_flags

Memory type flags.

__deepcopy__(_)[source]

Create a deep copy of this framebuffer, including the pixel data. Intended for use by copy.deepcopy().

retro_pixel_format

alias of c_int