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

_VEC3_COMPONENTS

_TIGHTLY_PACKED_STRIDE

_HEADLESS

Classes

AttributeSpec

Functions

build_legacy_vbg_layout([positions_size, ...]) → LayoutDescriptor

Headless-safe triple layout (VBO / NBO / CBO). Prefer this from code that imports

build_legacy_vbg_position_layout([component_size]) → LayoutDescriptor

Single position attribute at location 0 (e.g. line-strip outline).

convert_to_numpy(colors, normals, positions)

convert_to_numpy

create_vertex_buffer_group([draw_mode])

Create and return a VertexBufferGroup from arbitrary named attributes.

setup_vbg(colors, normals, positions[, draw_mode, ...]) → VertexBufferGroup

Create VBO

setup_vbg_from_mesh(mesh[, draw_mode]) → VertexBufferGroup

setup_position_vbg(positions_np) → VertexBufferGroup

setup position vbg

Module Contents

picogl.backend.gl.legacy.setup_vbg._VEC3_COMPONENTS[source]
picogl.backend.gl.legacy.setup_vbg._TIGHTLY_PACKED_STRIDE[source]
picogl.backend.gl.legacy.setup_vbg._HEADLESS[source]
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]
name[source]
index[source]
size[source]
dtype[source]
normalized[source]
stride[source]
offset[source]
role[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_vbg stubs; use legacy_position_normal_color_layout elsewhere.

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