picogl.backend.opengl

gl Backend Interface.

This module provides an interface for a gl backend implementation, which offers functionalities for managing OpenGL state, drawing meshes, managing materials, handling client-side arrays, and interacting with textures.

Classes:
GLBackend: A class defining the interface for the gl backend with

various methods for rendering and managing rendering states.

Attributes

LegacyPipeline

Classes

GLBindingStrategy

Upload CPU mesh data to a reusable GPUMesh.

LegacyBinding

Upload MeshData to a client-state LegacyMesh.

ModernBinding

Upload MeshData to a VAO-backed ModernMesh.

GLLegacyPipeline

Fixed-function matrix, light, and material operations.

LegacyPipelineProtocol

Fixed-function and immediate-mode pipeline operations (legacy gl only).

AbstractGLBackend

ALL rendering must go through this interface.

GLPipeline

Deprecated alias for LegacyPipelineProtocol.

Module Contents

class picogl.backend.opengl.GLBindingStrategy[source]

Bases: abc.ABC

Upload CPU mesh data to a reusable GPUMesh.

_last_gpu_mesh: picogl.backend.geometry.mesh.GPUMesh | None = None
abstract upload(mesh: picogl.renderer.meshdata.MeshData) picogl.backend.geometry.mesh.GPUMesh[source]
bind_mesh(mesh) None[source]

Deprecated: upload, bind, and remember mesh for the next draw.

draw(mesh, mode) None[source]

Deprecated: draw the last bound mesh, or upload on demand.

class picogl.backend.opengl.LegacyBinding[source]

Bases: GLBindingStrategy

Upload MeshData to a client-state LegacyMesh.

upload(mesh: picogl.renderer.meshdata.MeshData) picogl.backend.geometry.mesh.GPUMesh[source]
class picogl.backend.opengl.ModernBinding[source]

Bases: GLBindingStrategy

Upload MeshData to a VAO-backed ModernMesh.

upload(mesh: picogl.renderer.meshdata.MeshData) picogl.backend.geometry.mesh.GPUMesh[source]
upload_gpu_object(mesh: Any) picogl.backend.geometry.mesh.GPUMesh[source]

Wrap an object that already has vao / ebo / index_count.

bind_mesh(mesh) None[source]

Deprecated: upload, bind, and remember mesh for the next draw.

class picogl.backend.opengl.GLLegacyPipeline[source]

Fixed-function matrix, light, and material operations.

static set_matrix_mode_model_view()[source]
static set_matrix_mode_projection()[source]
static load_identity()[source]
static set_perspective(fovy, aspect, znear, zfar)[source]
static set_projection(fovy, aspect, znear, zfar)[source]
static translate(x, y, z)[source]
static set_light(position, light=GLLight.LIGHT0)[source]
static set_material(face, material)[source]
static set_color_material(face=GLFace.FRONT_AND_BACK, mode=GLColorMaterialMode.AMBIENT_AND_DIFFUSE)[source]
static set_color(rgba)[source]
set_uniform_color(color, alpha)[source]
static tex_coord2f(coord: picogl.backend.gl.state.texture.TexCoord2f)[source]
static vertex_3f(v1: picogl.backend.gl.state.texture.Vertex3f)[source]
picogl.backend.opengl.LegacyPipeline[source]
class picogl.backend.opengl.LegacyPipelineProtocol[source]

Bases: Protocol

Fixed-function and immediate-mode pipeline operations (legacy gl only).

set_matrix_mode_model_view()[source]
set_matrix_mode_projection()[source]
load_identity()[source]
set_perspective(fovy, aspect, znear, zfar)[source]
set_projection(fovy, aspect, znear, zfar)[source]
translate(x, y, z)[source]
set_light(position, light: Any = ...)[source]
set_material(face, material)[source]
set_color_material(face=..., mode=...)[source]
set_color(rgba)[source]
set_uniform_color(color, alpha)[source]
tex_coord2f(coord: picogl.backend.gl.state.texture.TexCoord2f)[source]
vertex_3f(v1: picogl.backend.gl.state.texture.Vertex3f)[source]
class picogl.backend.opengl.AbstractGLBackend[source]

Bases: abc.ABC

ALL rendering must go through this interface.

abstract set_blend(enabled: bool)[source]
abstract set_depth_test(enabled: bool)[source]
abstract set_depth_write(enabled: bool)[source]
abstract set_cull_face(enabled: bool)[source]
abstract set_line_width(width: float)[source]
abstract set_polygon_mode(*args)[source]
abstract set_lighting(enabled: bool)[source]
abstract set_uniform_color(color: tuple, alpha: float)[source]
abstract draw_elements(mode: int, indices)[source]
class picogl.backend.opengl.GLPipeline[source]

Bases: picogl.backend.legacy.core.pipeline.LegacyPipelineProtocol, Protocol

Deprecated alias for LegacyPipelineProtocol.

Do not use for new code. Modern rendering uses ShaderPipeline.