picogl.backend.gl.api ===================== .. py:module:: picogl.backend.gl.api .. autoapi-nested-parse:: This module provides bindings and utilities for interacting with OpenGL buffers, vertex arrays, texture, client states, and draw operations. These functions facilitate working with OpenGL through abstractions and are commonly utilized in graphics programming for setting up and rendering graphics pipelines. Exports a variety of OpenGL utility functions, including buffer operations, vertex and texture handling, and client state management. Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/picogl/backend/gl/api/blending/index /autoapi/picogl/backend/gl/api/boolean/index /autoapi/picogl/backend/gl/api/buffer/index /autoapi/picogl/backend/gl/api/capabilities/index /autoapi/picogl/backend/gl/api/clear/index /autoapi/picogl/backend/gl/api/client_state/index /autoapi/picogl/backend/gl/api/color/index /autoapi/picogl/backend/gl/api/depth/index /autoapi/picogl/backend/gl/api/dpr/index /autoapi/picogl/backend/gl/api/draw/index /autoapi/picogl/backend/gl/api/enable/index /autoapi/picogl/backend/gl/api/error/index /autoapi/picogl/backend/gl/api/flush/index /autoapi/picogl/backend/gl/api/frame/index /autoapi/picogl/backend/gl/api/framebuffer/index /autoapi/picogl/backend/gl/api/get_integerv/index /autoapi/picogl/backend/gl/api/get_string/index /autoapi/picogl/backend/gl/api/gl_int/index /autoapi/picogl/backend/gl/api/glcleanup/index /autoapi/picogl/backend/gl/api/hint/index /autoapi/picogl/backend/gl/api/legacy/index /autoapi/picogl/backend/gl/api/light/index /autoapi/picogl/backend/gl/api/line/index /autoapi/picogl/backend/gl/api/material/index /autoapi/picogl/backend/gl/api/matrix/index /autoapi/picogl/backend/gl/api/point/index /autoapi/picogl/backend/gl/api/pointer/index /autoapi/picogl/backend/gl/api/polygon_mode/index /autoapi/picogl/backend/gl/api/rotate/index /autoapi/picogl/backend/gl/api/shader/index /autoapi/picogl/backend/gl/api/target/index /autoapi/picogl/backend/gl/api/texture/index /autoapi/picogl/backend/gl/api/version/index /autoapi/picogl/backend/gl/api/vertex/index Functions --------- .. autoapisummary:: picogl.backend.gl.api.gl_buffer_data picogl.backend.gl.api.gl_generate_buffers picogl.backend.gl.api.gl_upload_float_buffer picogl.backend.gl.api.gl_upload_ushort_buffer picogl.backend.gl.api.gl_disable_legacy_client_state picogl.backend.gl.api.gl_enable_legacy_client_state picogl.backend.gl.api.gl_draw_arrays picogl.backend.gl.api.gl_draw_arrays_spec picogl.backend.gl.api.gl_draw_elements picogl.backend.gl.api.gl_draw_elements_spec picogl.backend.gl.api.gl_bind_elements picogl.backend.gl.api.gl_flush picogl.backend.gl.api.gl_color_array_pointer picogl.backend.gl.api.gl_color_pointer_from_spec picogl.backend.gl.api.gl_normal_array_pointer picogl.backend.gl.api.gl_normal_pointer_from_spec picogl.backend.gl.api.gl_texcoord_array_pointer picogl.backend.gl.api.gl_vertex_array_pointer picogl.backend.gl.api.gl_vertex_pointer_from_spec picogl.backend.gl.api.gl_bind_vertex_array picogl.backend.gl.api.gl_bind_array_buffer picogl.backend.gl.api.gl_bound_vertex_attrib_arrays picogl.backend.gl.api.gl_vertex_attrib_pointer picogl.backend.gl.api.gl_enable_vertex_array picogl.backend.gl.api.gl_generate_vertex_array picogl.backend.gl.api.gl_normal_3f picogl.backend.gl.api.gl_vertex_3f picogl.backend.gl.api.gl_vertex_coord picogl.backend.gl.api.gl_vertex_line picogl.backend.gl.api.gl_bind_buffer picogl.backend.gl.api.gl_get_integerv picogl.backend.gl.api.gl_active_texture picogl.backend.gl.api.gl_get_active_texture0 picogl.backend.gl.api.gl_bind_texture picogl.backend.gl.api.gl_gen_textures picogl.backend.gl.api.gl_compressed_tex_image picogl.backend.gl.api.gl_teximage2d picogl.backend.gl.api.gl_teximage3d picogl.backend.gl.api.gl_generate_mipmap picogl.backend.gl.api.gl_tex_parameter Package Contents ---------------- .. py:function:: gl_buffer_data(target: picogl.backend.gl.enums.GLBufferTarget = GLBufferTarget.ARRAY, size: int = 0, data=None, usage_hint: picogl.backend.gl.enums.GLUsageHint = GLUsageHint.STATIC_DRAW) gl bind buffer .. py:function:: gl_generate_buffers(num: int = 1) -> Any Generate buffer object names. A request for one name returns a Python ``int``. ``glGenBuffers(1)`` otherwise returns a length-1 array, which ``glIsBuffer`` does not accept as a buffer name. :param num: How many names to generate :return: One buffer name, or the array of names when *num* is greater than 1 .. py:function:: gl_upload_float_buffer(data: list[float], buffer_target: picogl.backend.gl.enums.GLBufferTarget = GLBufferTarget.ARRAY) -> None Upload float vertex/attribute data to the bound buffer. .. py:function:: gl_upload_ushort_buffer(data: list[int], buffer_target: picogl.backend.gl.enums.GLBufferTarget = GLBufferTarget.ELEMENT) -> None Upload unsigned-short index data to the bound element buffer. .. py:function:: gl_disable_legacy_client_state(state: picogl.backend.gl.state.client.GLClientState) -> None gl disable client state .. py:function:: gl_enable_legacy_client_state(state: picogl.backend.gl.state.client.GLClientState) -> None gl legacy client state .. py:function:: gl_draw_arrays(index_count: int, mode: picogl.backend.gl.enums.GLDrawMode | int, first: int = 0) -> None Issue ``glDrawArrays`` with PicoGL draw-mode enums or raw gl constants. .. py:function:: gl_draw_arrays_spec(spec: picogl.backend.modern.core.vertex.array.draw_spec.DrawSpec) gl draw arrays from spec .. py:function:: gl_draw_elements(index_count: int, dtype: int | None = GLIndexType.UNSIGNED_INT, mode: picogl.backend.gl.enums.GLDrawMode | int | None = GLDrawMode.TRIANGLES, pointer: Any | None = None, offset: int = 0) -> None Issue ``glDrawElements``. *pointer* may be a client index array, ``None`` (EBO bound), or omitted to use *offset*. .. py:function:: gl_draw_elements_spec(spec: picogl.backend.modern.core.vertex.array.draw_spec.DrawSpec) gl draw elements from spec .. py:function:: gl_bind_elements(index_buffer, size: int) -> None Bind ELEMENT buffer and draw triangles (ushort indices). .. py:function:: gl_flush() -> None Flush the OpenGL command pipeline. .. py:function:: gl_color_array_pointer(pointer: numpy.ndarray, size: int = 4, num_type: picogl.backend.gl.enums.GLNumeric = GLNumeric.FLOAT, stride: int = 0) gl color pointer for mesh binding. .. py:function:: gl_color_pointer_from_spec(attr: picogl.gpu.buffers.attributes.AttributeSpec) gl color pointer .. py:function:: gl_normal_array_pointer(pointer: numpy.ndarray, stride: int = 0, num_type: picogl.backend.gl.enums.GLNumeric = GLNumeric.FLOAT) gl normal pointer for mesh binding. .. py:function:: gl_normal_pointer_from_spec(attr: picogl.gpu.buffers.attributes.AttributeSpec) gl normal pointer .. py:function:: gl_texcoord_array_pointer(pointer: numpy.ndarray, size: int = 2, stride: int = 0, num_type: picogl.backend.gl.enums.GLNumeric = GLNumeric.FLOAT) gl texcoord pointer for mesh binding. .. py:function:: gl_vertex_array_pointer(pointer: numpy.ndarray | int, size: int = 3, num_type: picogl.backend.gl.enums.GLNumeric = GLNumeric.FLOAT, stride: int = 0) gl vertex pointer for mesh binding. .. py:function:: gl_vertex_pointer_from_spec(attr: picogl.gpu.buffers.attributes.AttributeSpec) gl legacy client state .. py:function:: gl_bind_vertex_array(vao: int) -> None Binds a vertex array object (VAO) in OpenGL. This function wraps the OpenGL `glBindVertexArray` function to bind a specific VAO for subsequent OpenGL operations. Parameters: vao: int The ID of the vertex array object to bind. Must not be None and must be a non-negative integer. .. py:function:: gl_bind_array_buffer(buffer, index: int = 0, size: int = 3, stride: int = 0) -> None Bind an ARRAY buffer and set its vertex attrib pointer. .. py:function:: gl_bound_vertex_attrib_arrays(vertex_attrib_arrays: list[int]) -> collections.abc.Iterator[None] Enable vertex attrib arrays for the block, then disable them. .. py:function:: gl_vertex_attrib_pointer(index: int, size: int, num_type: picogl.backend.gl.enums.GLNumeric = GLNumeric.FLOAT, normalized: picogl.boolean.GLBoolean = GLBoolean.FALSE, stride: int = 0, offset: Optional[Any] = None) -> None Issue ``glVertexAttribPointer``. *offset* may be a byte offset (``int``), ``None``, or a ``ctypes.c_void_p``. .. py:function:: gl_enable_vertex_array(location: int) -> Any gl_enable_vertex_array :param location: int .. py:function:: gl_generate_vertex_array(num: int = 1) -> Any gl_generate_vertex_array :param num: int .. py:function:: gl_normal_3f(x: float, y: float, z: float) -> None Set the current normal vector. .. py:function:: gl_vertex_3f(x: float, y: float, z: float) -> None vertex 3f .. py:function:: gl_vertex_coord(coord: molib.pdb.coordinate.coordinate.Coordinate3D) -> None gl vertex coord .. py:function:: gl_vertex_line(coord_end: molib.pdb.coordinate.coordinate.Coordinate3D, coord_start: molib.pdb.coordinate.coordinate.Coordinate3D) -> None Emit a GL_LINES segment from start to end. .. py:function:: gl_bind_buffer(target: int, vbo_id: int | None) Binds a buffer object to a specified binding point in the OpenGL context. This function wraps the OpenGL glBindBuffer call, which is used to bind a buffer object to the specified target. Once bound, the buffer becomes the active buffer for the target, allowing subsequent OpenGL commands to operate on it. Parameters: target : int The target to which the buffer is to be bound. Common examples include GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER, etc. ebo_id : int or None The name (ID) of the buffer object to bind. If None is provided, the target will be unbound, and no buffer will be associated with it. .. py:function:: gl_get_integerv(val) -> Any get integer value .. py:function:: gl_active_texture(texture: int | picogl.texture.gltexture.GLTexture) -> None Issue ``glActiveTexture``. .. py:function:: gl_get_active_texture0() -> None Select texture unit 0. .. py:function:: gl_bind_texture(tex_id: int, target: picogl.texture.gltexture.GLTexture = GLTexture.TEXTURE_2D) -> None Issue ``glBindTexture``. .. py:function:: gl_gen_textures(number: int = 1) -> int Issue ``glGenTextures``. .. py:function:: gl_compressed_tex_image(byte_array: CompressedTexData, gl_format: OpenGL.constant.FloatConstant | OpenGL.constant.IntConstant | OpenGL.constant.LongConstant | OpenGL.constant.StringConstant | OpenGL.constant.Constant, height: int, level: int, size: int, width: int) -> None Issue ``glCompressedTexImage2D`` for a 2D texture. PyOpenGL's wrapped ``glCompressedTexImage2D`` omits ``imageSize`` and derives it from ``data``. Passing an explicit size as the 7th argument makes PyOpenGL treat that int as the data pointer and raises ``NumberHandler`` / ``arrayByteCount``. .. py:function:: gl_teximage2d(target: int, level: int, internalformat: OpenGL.constant.FloatConstant | OpenGL.constant.IntConstant | OpenGL.constant.LongConstant | OpenGL.constant.StringConstant | OpenGL.constant.Constant, width: int, height: int, border: int, format: OpenGL.constant.FloatConstant | OpenGL.constant.IntConstant | OpenGL.constant.LongConstant | OpenGL.constant.StringConstant | OpenGL.constant.Constant, num_type: int = GLNumeric.UNSIGNED_BYTE, data: bytes | numpy.ndarray | None = None) -> None Issue ``glTexImage2D``. .. py:function:: gl_teximage3d(target: int, level: int, internalformat: OpenGL.constant.FloatConstant | OpenGL.constant.IntConstant | OpenGL.constant.LongConstant | OpenGL.constant.StringConstant | OpenGL.constant.Constant, width: int, height: int, depth: int, border: int, format: OpenGL.constant.FloatConstant | OpenGL.constant.IntConstant | OpenGL.constant.LongConstant | OpenGL.constant.StringConstant | OpenGL.constant.Constant, num_type: int, data: bytes | numpy.ndarray | None = None) -> None Issue ``glTexImage3D``. .. py:function:: gl_generate_mipmap(target: picogl.texture.gltexture.GLTexture = GLTexture.TEXTURE_2D) -> None Generate mipmaps for the currently bound texture. .. py:function:: gl_tex_parameter(target: int, pname: picogl.texture.gltexture.GLTexture, param: Union[picogl.texture.gltexparam.GLTexParam, picogl.core.texture_clamp.GLTextureClamp]) -> None Issue ``glTexParameteri``.