picogl.backend.gl.legacy.setup_vbg ================================== .. py:module:: picogl.backend.gl.legacy.setup_vbg .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: picogl.backend.gl.legacy.setup_vbg._VEC3_COMPONENTS picogl.backend.gl.legacy.setup_vbg._TIGHTLY_PACKED_STRIDE picogl.backend.gl.legacy.setup_vbg._HEADLESS Classes ------- .. autoapisummary:: picogl.backend.gl.legacy.setup_vbg.AttributeSpec Functions --------- .. autoapisummary:: picogl.backend.gl.legacy.setup_vbg.build_legacy_vbg_layout picogl.backend.gl.legacy.setup_vbg.build_legacy_vbg_position_layout picogl.backend.gl.legacy.setup_vbg.convert_to_numpy picogl.backend.gl.legacy.setup_vbg.create_vertex_buffer_group picogl.backend.gl.legacy.setup_vbg.setup_vbg picogl.backend.gl.legacy.setup_vbg.setup_vbg_from_mesh picogl.backend.gl.legacy.setup_vbg.setup_position_vbg Module Contents --------------- .. py:data:: _VEC3_COMPONENTS .. py:data:: _TIGHTLY_PACKED_STRIDE .. py:data:: _HEADLESS .. py:class:: 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) .. py:attribute:: name .. py:attribute:: index .. py:attribute:: size .. py:attribute:: dtype .. py:attribute:: normalized .. py:attribute:: stride .. py:attribute:: offset .. py:attribute:: role .. py:function:: build_legacy_vbg_layout(positions_size: int = _VEC3_COMPONENTS, normals_size: int = _VEC3_COMPONENTS, colors_size: int = _VEC3_COMPONENTS) -> LayoutDescriptor Headless-safe triple layout (VBO / NBO / CBO). Prefer this from code that imports ``setup_vbg`` stubs; use ``legacy_position_normal_color_layout`` elsewhere. .. py:function:: build_legacy_vbg_position_layout(component_size: int = 3) -> LayoutDescriptor Single position attribute at location 0 (e.g. line-strip outline). .. py:function:: convert_to_numpy(colors, normals, positions) convert_to_numpy .. py:function:: create_vertex_buffer_group(draw_mode: int = GLDrawMode.TRIANGLE_STRIP, **attributes) Create and return a VertexBufferGroup from arbitrary named attributes. :param draw_mode: OpenGL draw mode (default: GL_TRIANGLE_STRIP). :type draw_mode: int :param attributes: 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). :type attributes: dict[str, tuple[np.ndarray, int]] .. rubric:: Example vbg = create_vertex_buffer_group( vertices=(positions, 3), nbo=(normals, 3), cbo=(colors, 4), # RGBA colors ) .. py:function:: 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 Create VBO .. py:function:: setup_vbg_from_mesh(mesh: picogl.renderer.meshdata.MeshData, draw_mode: int = GLDrawMode.TRIANGLE_STRIP) -> VertexBufferGroup .. py:function:: setup_position_vbg(positions_np: numpy.ndarray) -> VertexBufferGroup setup position vbg