picogl.backend.gl.legacy.setup_vbg
Module to handle headless-safe OpenGL vertex buffer group (VBG) management.
This module provides functions and classes to create and manage vertex buffers in headless and non-headless environments, ensuring compatibility with OpenGL- based rendering pipelines. It includes utilities to define attribute layouts, convert data to numpy arrays, and set up vertex buffer groups (VBGs) for use in rendering workflows.
Attributes
Classes
Functions
|
Headless-safe triple layout (VBO / NBO / CBO). Prefer this from code that imports |
|
Single position attribute at location 0 (e.g. line-strip outline). |
|
convert_to_numpy |
|
Create and return a VertexBufferGroup from arbitrary named attributes. |
|
Create VBO |
|
|
|
setup position vbg |
Module Contents
- class picogl.backend.gl.legacy.setup_vbg.AttributeSpec(name: str, index: int, size: int, dtype: picogl.backend.gl.enums.GLNumeric, normalized: picogl.boolean.GLBoolean, stride: int, offset: int, role: picogl.gpu.buffers.vertex.aliases.VertexBufferRole = VertexBufferRole.VBO)[source]
- picogl.backend.gl.legacy.setup_vbg.build_legacy_vbg_layout(positions_size: int = _VEC3_COMPONENTS, normals_size: int = _VEC3_COMPONENTS, colors_size: int = _VEC3_COMPONENTS) LayoutDescriptor[source]
Headless-safe triple layout (VBO / NBO / CBO). Prefer this from code that imports
setup_vbgstubs; uselegacy_position_normal_color_layoutelsewhere.
- picogl.backend.gl.legacy.setup_vbg.build_legacy_vbg_position_layout(component_size: int = 3) LayoutDescriptor[source]
Single position attribute at location 0 (e.g. line-strip outline).
- picogl.backend.gl.legacy.setup_vbg.convert_to_numpy(colors, normals, positions)[source]
convert_to_numpy
- picogl.backend.gl.legacy.setup_vbg.create_vertex_buffer_group(draw_mode: int = GLDrawMode.TRIANGLE_STRIP, **attributes)[source]
Create and return a VertexBufferGroup from arbitrary named attributes.
- Parameters:
draw_mode (int) – OpenGL draw mode (default: GL_TRIANGLE_STRIP).
attributes (dict[str, tuple[np.ndarray, int]]) – Named attributes where the key is the buffer name (VBOType.VBO, VBOType.NBO, VBOType.CBO, …) and the value is a tuple of (array, size), where size is the number of components per vertex (e.g., 2 for UVs, 3 for XYZ, 4 for RGBA).
Example
- vbg = create_vertex_buffer_group(
vertices=(positions, 3), nbo=(normals, 3), cbo=(colors, 4), # RGBA colors
)
- picogl.backend.gl.legacy.setup_vbg.setup_vbg(colors: numpy.ndarray, normals: numpy.ndarray, positions: numpy.ndarray, draw_mode: int = GLDrawMode.TRIANGLE_STRIP, positions_size: int = _VEC3_COMPONENTS, normals_size: int = _VEC3_COMPONENTS, colors_size: int = _VEC3_COMPONENTS) VertexBufferGroup[source]
Create VBO
- picogl.backend.gl.legacy.setup_vbg.setup_vbg_from_mesh(mesh: picogl.renderer.meshdata.MeshData, draw_mode: int = GLDrawMode.TRIANGLE_STRIP) VertexBufferGroup[source]
- picogl.backend.gl.legacy.setup_vbg.setup_position_vbg(positions_np: numpy.ndarray) VertexBufferGroup[source]
setup position vbg