libretro.api.video.context

Hardware rendering API context types and callbacks.

Module Attributes

HW_FRAME_BUFFER_VALID

Passed to retro_video_refresh_t to signal that the next video frame should be rendered with the GPU context state instead of a software-accessible framebuffer.

retro_hw_context_reset_t

Notify the core that the hardware rendering context has been (re)created or destroyed.

retro_hw_get_current_framebuffer_t

Return the current frontend-managed hardware framebuffer object.

retro_hw_get_proc_address_t

Look up a function pointer in the active hardware rendering API.

Classes

HardwareContext

Hardware rendering API supported by libretro.

retro_hw_render_callback

Description of the hardware rendering context a core requires, with callbacks for reacting to or querying the context.

class HardwareContext[source]

Bases: IntEnum

Hardware rendering API supported by libretro.

Corresponds to retro_hw_context_type in libretro.h.

See also

VideoDriver

The Protocol that implements one or more of these context types.

NONE = 0

Software rendering only.

Note

The active VideoDriver may still use a hardware rendering API, but it won’t be exposed to the core.

OPENGL = 1

OpenGL 2.x, or a newer OpenGL version with the compatibility profile.

OPENGLES2 = 2

OpenGL ES 2.0.

OPENGL_CORE = 3

OpenGL 3.2+ core profile.

OPENGLES3 = 4

OpenGL ES 3.0.

OPENGLES_VERSION = 5

OpenGL ES with version specified by version_major and version_minor.

VULKAN = 6

Vulkan.

Note

libretro.py doesn’t currently support Vulkan contexts. Pull requests are welcome!

DIRECT3D = 7
Deprecated:

Use D3D11, D3D10, D3D12, or D3D9 instead.

D3D11 = 7

Direct3D 11.

Note

libretro.py doesn’t currently support Direct3D contexts. Pull requests are welcome!

D3D10 = 8

Direct3D 10.

Note

libretro.py doesn’t currently support Direct3D contexts. Pull requests are welcome!

D3D12 = 9

Direct3D 12.

Note

libretro.py doesn’t currently support Direct3D contexts. Pull requests are welcome!

D3D9 = 10

Direct3D 9.

Note

libretro.py doesn’t currently support Direct3D contexts. Pull requests are welcome!

__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)

retro_hw_context_reset_t

Notify the core that the hardware rendering context has been (re)created or destroyed.

Registered by the core and called by the frontend when a hardware rendering context is initialized, lost, or about to be torn down. A core should treat all GPU resources as invalid after this is called as a reset and recreate them; for a destroy notification, it should simply free its resources without further GPU calls.

Corresponds to retro_hw_context_reset_t in libretro.h.

retro_hw_get_current_framebuffer_t

Return the current frontend-managed hardware framebuffer object.

Registered by the frontend and called by the core to obtain the framebuffer it should render into for the current frame.

Returns:

An opaque c_uintptr identifying the framebuffer (typically an OpenGL FBO ID). The value may change from frame to frame.

Note

This callback exists for historical reasons and is only meaningful for OpenGL contexts.

Corresponds to retro_hw_get_current_framebuffer_t in libretro.h.

retro_hw_get_proc_address_t

Look up a function pointer in the active hardware rendering API.

Registered by the frontend and called by the core to obtain entry points such as glClear or other GPU API functions.

Parameters:

sym – Name of the symbol to look up, as a bytes-like object.

Returns:

A c_void_ptr to the requested function, or None if the symbol could not be resolved.

Note

The returned pointer must be cast to the correct function signature before use.

Corresponds to retro_hw_get_proc_address_t in libretro.h.

class retro_hw_render_callback[source]

Bases: Structure

Description of the hardware rendering context a core requires, with callbacks for reacting to or querying the context.

Corresponds to retro_hw_render_callback in libretro.h.

>>> from libretro.api.video import retro_hw_render_callback, HardwareContext
>>> cb = retro_hw_render_callback()
>>> cb.context_type == HardwareContext.NONE
True
classmethod __new__(*args, **kwargs)
__init__(context_type=HardwareContext.NONE, context_reset=None, get_current_framebuffer=None, get_proc_address=None, depth=False, stencil=False, bottom_left_origin=False, version_major=0, version_minor=0, cache_context=False, context_destroy=None, debug_context=False)[source]

Create a new retro_hw_render_callback.

context_type

Hardware rendering API to use.

context_reset

Called when the rendering context is created or reset.

See also

VideoDriver.reinit()

The suggested method to call this callback.

get_current_framebuffer

Return the current hardware framebuffer. Set by the frontend.

Note

This callback exists for historical reasons and is only meaningful for OpenGL contexts.

See also

VideoDriver.current_framebuffer

The suggested property to implement this callback.

get_proc_address

Looks up a rendering API function by name. Set by the frontend.

See also

VideoDriver.get_proc_address()

The suggested method to implement this callback.

depth

Whether the framebuffer should have a depth component.

Note

This field exists for historical reasons and is only meaningful for OpenGL contexts.

stencil

Whether the framebuffer should have a stencil component.

Note

This field exists for historical reasons and is only meaningful for OpenGL contexts.

bottom_left_origin

Whether to use bottom-left origin convention.

version_major

Major version number for the rendering context.

version_minor

Minor version number for the rendering context.

cache_context

Whether the frontend should avoid resetting the context.

context_destroy

Called before the context is destroyed.

debug_context

Whether to create a debug rendering context.

__deepcopy__(_)[source]

Return a deep copy of this object. Intended for use with copy.deepcopy().

HW_FRAME_BUFFER_VALID = c_void_p(18446744073709551615)

Passed to retro_video_refresh_t to signal that the next video frame should be rendered with the GPU context state instead of a software-accessible framebuffer.

retro_hw_context_type

alias of c_int