simvx.core.backend

Abstract backend interfaces for rendering.

This module defines the interfaces that rendering backends must implement. Backend implementations (SDL3, Vulkan) should provide concrete implementations of these abstract classes.

Module Contents

Classes

RenderBackend

Abstract interface for rendering backends.

Renderer2D

2D rendering interface.

Renderer3D

3D rendering interface.

Data

log

API

simvx.core.backend.log[source]

‘getLogger(…)’

class simvx.core.backend.RenderBackend[source]

Bases: typing.Protocol

Abstract interface for rendering backends.

Any rendering backend (SDL3, Vulkan, etc.) must implement these methods to be compatible with the SimVX core engine.

init(width: int, height: int, title: str) None[source]

Initialize the backend with window dimensions and title.

Args: width: Window width in pixels. height: Window height in pixels. title: Window title text.

begin_frame() None[source]

Called at the beginning of each frame.

Used to clear buffers, reset state, and prepare for rendering.

end_frame() None[source]

Called at the end of each frame.

Used to present the rendered frame to the display.

render_mesh(mesh: simvx.core.graphics.mesh.BaseMesh, material: simvx.core.graphics.material.BaseMaterial, model_matrix: object) None[source]

Render a mesh with the given material and transform.

Args: mesh: The mesh geometry to render. material: Material defining appearance. model_matrix: World-space transform matrix.

cleanup() None[source]

Clean up backend resources.

Called when the application shuts down.

__slots__

()

classmethod __init_subclass__(*args, **kwargs)
classmethod __class_getitem__(item)
class simvx.core.backend.Renderer2D[source]

Bases: typing.Protocol

2D rendering interface.

Backends supporting 2D rendering should implement this protocol.

draw_filled_rect(x: float, y: float, width: float, height: float, colour: tuple[int, int, int, int]) None[source]

Draw a filled rectangle.

Args: x: Left edge x coordinate. y: Top edge y coordinate. width: Rectangle width. height: Rectangle height. colour: RGBA colour tuple (0-255).

draw_line(x1: float, y1: float, x2: float, y2: float, colour: tuple[int, int, int, int]) None[source]

Draw a line.

Args: x1: Start x coordinate. y1: Start y coordinate. x2: End x coordinate. y2: End y coordinate. colour: RGBA colour tuple (0-255).

draw_text(text: str, x: float, y: float, scale: float, colour: tuple[int, int, int, int]) None[source]

Draw text.

Args: text: Text string to render. x: X coordinate. y: Y coordinate. scale: Text scale/size. colour: RGBA colour tuple (0-255).

text_width(text: str, scale: float) float[source]

Get the width of text when rendered.

Args: text: Text string to measure. scale: Text scale/size.

Returns: Width of the text in pixels.

__slots__

()

classmethod __init_subclass__(*args, **kwargs)
classmethod __class_getitem__(item)
class simvx.core.backend.Renderer3D[source]

Bases: typing.Protocol

3D rendering interface.

Backends supporting 3D rendering should implement this protocol.

render(camera_view_matrix: object, camera_projection_matrix: object) None[source]

Render the scene with the given camera matrices.

Args: camera_view_matrix: Camera view matrix (glm.mat4 or similar). camera_projection_matrix: Camera projection matrix.

__slots__

()

classmethod __init_subclass__(*args, **kwargs)
classmethod __class_getitem__(item)