picogl.backend.opengl
gl Backend Interface.
This module provides an interface for a gl backend implementation, which offers functionalities for managing OpenGL state, draw meshes, managing materials, handling client-side arrays, and interacting with texture.
- Classes:
- GLBackend: A class defining the interface for the gl backend with
various methods for rendering and managing rendering states.
Attributes
Classes
Upload CPU mesh data to a reusable |
|
Upload |
|
Upload |
|
Fixed-function matrix, light, and material operations. |
|
Fixed-function and immediate-mode pipeline operations (legacy gl only). |
|
ALL rendering must go through this interface. |
|
Deprecated alias for |
Module Contents
- class picogl.backend.opengl.GLBindingStrategy[source]
Bases:
abc.ABCUpload 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]
- class picogl.backend.opengl.LegacyBinding[source]
Bases:
GLBindingStrategyUpload
MeshDatato a client-stateLegacyMesh.
- class picogl.backend.opengl.ModernBinding[source]
Bases:
GLBindingStrategyUpload
MeshDatato a VAO-backedModernMesh.- upload_gpu_object(mesh: Any) picogl.backend.geometry.mesh.GPUMesh[source]
Wrap an object that already has
vao/ebo/index_count.
- class picogl.backend.opengl.GLLegacyPipeline[source]
Fixed-function matrix, light, and material operations.
- static set_matrix_mode_model_view()[source]
Sets the current matrix mode to model-view.
This function sets the current OpenGL matrix mode to model-view, allowing subsequent matrix operations to affect the model-view matrix.
@return: None
- static set_matrix_mode_projection()[source]
Sets the matrix mode to the default, which is the matrix mode
- static load_identity()[source]
Provides a static method to reset the current OpenGL matrix to the identity matrix.
This method is used to simplify transformations by resetting the matrix to a default state, which is the identity matrix. It interacts with the OpenGL graphic library to perform this operation.
@return: None
- static set_perspective(fovy: float, aspect: float, znear: float, zfar: float)[source]
set perspective
- static set_projection(fovy: float, aspect: float, znear: float, zfar: float)[source]
set projection
- static translate(x: float, y: float, z: float) None[source]
Translates the current coordinate system by the given x, y, and z amounts.
This method applies a translation transformation to the current coordinate system. The parameters x, y, and z represent the translation distances along the respective axes.
- static set_light(position, light: picogl.backend.gl.state.fill.GLLight = GLLight.LIGHT0) None[source]
Sets the light source’s position in the OpenGL context.
Sets the specified light source’s position based on the given parameters, allowing configuration of light sources within the OpenGL rendering pipeline.
- Parameters:
position – The position of the light in 3D space, defined as a list or tuple of four float values (x, y, z, w coordinates).
light – The specific light source to be set, defined as an instance of the GLLight enum. Defaults to GLLight.LIGHT0.
- Returns:
None
- static set_material(face, material: picogl.backend.gl.phong.material.PhongMaterial) None[source]
Sets the material properties for a specified face using the provided PhongMaterial parameters. This method adjusts the ambient, diffuse, specular, and shininess values for the face in the OpenGL rendering context.
- Parameters:
face – The specified face of the object to which the material properties are applied.
material – An instance of PhongMaterial that encapsulates the ambient, diffuse, specular, and shininess properties to be set for the specified face.
- Returns:
None
- static set_color_material(face: picogl.backend.gl.state.fill.GLFace = GLFace.FRONT_AND_BACK, mode: picogl.backend.gl.state.fill.GLColorMaterialMode = GLColorMaterialMode.AMBIENT_AND_DIFFUSE) None[source]
Sets the color material mode for the specified face.
This method sets the material property or combination of properties in the current OpenGL context to track the current color. The specified face and mode determine which material parameters will track the current color.
- Parameters:
face (GLFace) – Specifies which face(s) of the material to apply the color-material mode to. Default is GLFace.FRONT_AND_BACK.
mode (GLColorMaterialMode) – Specifies the color material mode to set. Default is GLColorMaterialMode.AMBIENT_AND_DIFFUSE.
- static set_color(rgba: tuple[float, float, float, float]) None[source]
Sets the current drawing color for subsequent OpenGL rendering.
This method sets the RGBA color using the provided tuple. Each of the four components in the tuple should range between 0.0 and 1.0. The color is applied to all OpenGL primitives that are drawn after calling this method.
- static set_rgba_color(rgba_color: picogl.core.rgbcolor.RGBAColor) None[source]
Sets the RGBA color for the rendering pipeline.
This method updates the color used in the rendering pipeline by providing a new RGBA color and passing it to the legacy OpenGL color setting function.
- Parameters:
rgba_color (RGBAColor) – A tuple or object representing RGBA color, where
R
G
B
[0 (and A are values in the range)
1].
- Returns:
None
- static tex_coord2f(coord: picogl.backend.gl.state.texture.TexCoord2f) None[source]
Provides functionality to pass a 2-dimensional texture coordinate to the OpenGL rendering pipeline. This method is a static utility designed to make it convenient to set texture coordinates using a given TexCoord2f object.
- Parameters:
coord (TexCoord2f) – A data structure containing the u and v components of the 2D texture coordinate.
- Returns:
This method does not return a value.
- Return type:
None
- Raises:
Any exception raised by the underlying gl_tex_coord2f function call. –
- static vertex_3f(v1: picogl.backend.gl.state.texture.Vertex3f)[source]
Provides a static method to process a Vertex3f object and pass its coordinates to a corresponding OpenGL function.
- class picogl.backend.opengl.LegacyPipelineProtocol[source]
Bases:
ProtocolFixed-function and immediate-mode pipeline operations (legacy gl only).
- 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.ABCALL rendering must go through this interface.
- class picogl.backend.opengl.GLPipeline[source]
Bases:
picogl.backend.legacy.core.pipeline.LegacyPipelineProtocol,ProtocolDeprecated alias for
LegacyPipelineProtocol.Do not use for new code. Modern rendering uses
ShaderPipeline.