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.

API

class simvx.core.backend.RenderBackend

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

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

Called at the beginning of each frame.

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

end_frame() None

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

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

Clean up backend resources.

Called when the application shuts down.

__slots__

()

classmethod __init_subclass__(*args, **kwargs)
class simvx.core.backend.Renderer2D

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, color: tuple[int, int, int, int]) None

Draw a filled rectangle.

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

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

Draw a line.

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

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

Draw text.

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

text_width(text: str, scale: float) float

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)
class simvx.core.backend.Renderer3D

Bases: typing.Protocol

3D rendering interface.

Backends supporting 3D rendering should implement this protocol.

render(camera_view_matrix: object, camera_projection_matrix: object) None

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)