picogl.backend.gl.api
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
- picogl.backend.gl.api.blending
- picogl.backend.gl.api.boolean
- picogl.backend.gl.api.buffer
- picogl.backend.gl.api.capabilities
- picogl.backend.gl.api.clear
- picogl.backend.gl.api.client_state
- picogl.backend.gl.api.color
- picogl.backend.gl.api.depth
- picogl.backend.gl.api.dpr
- picogl.backend.gl.api.draw
- picogl.backend.gl.api.enable
- picogl.backend.gl.api.error
- picogl.backend.gl.api.flush
- picogl.backend.gl.api.frame
- picogl.backend.gl.api.framebuffer
- picogl.backend.gl.api.get_integerv
- picogl.backend.gl.api.get_string
- picogl.backend.gl.api.gl_int
- picogl.backend.gl.api.glcleanup
- picogl.backend.gl.api.hint
- picogl.backend.gl.api.legacy
- picogl.backend.gl.api.light
- picogl.backend.gl.api.line
- picogl.backend.gl.api.material
- picogl.backend.gl.api.matrix
- picogl.backend.gl.api.point
- picogl.backend.gl.api.pointer
- picogl.backend.gl.api.polygon_mode
- picogl.backend.gl.api.rotate
- picogl.backend.gl.api.shader
- picogl.backend.gl.api.target
- picogl.backend.gl.api.texture
- picogl.backend.gl.api.version
- picogl.backend.gl.api.vertex
Functions
|
gl bind buffer |
|
Generate buffer object names. |
|
Upload float vertex/attribute data to the bound buffer. |
|
Upload unsigned-short index data to the bound element buffer. |
|
gl disable client state |
|
gl legacy client state |
|
Issue |
|
gl draw arrays from spec |
|
Issue |
|
gl draw elements from spec |
|
Bind ELEMENT buffer and draw triangles (ushort indices). |
|
Flush the OpenGL command pipeline. |
|
gl color pointer for mesh binding. |
gl color pointer |
|
|
gl normal pointer for mesh binding. |
gl normal pointer |
|
|
gl texcoord pointer for mesh binding. |
|
gl vertex pointer for mesh binding. |
gl legacy client state |
|
|
Binds a vertex array object (VAO) in OpenGL. |
|
Bind an ARRAY buffer and set its vertex attrib pointer. |
|
Enable vertex attrib arrays for the block, then disable them. |
|
Issue |
|
gl_enable_vertex_array |
|
gl_generate_vertex_array |
|
Set the current normal vector. |
|
vertex 3f |
|
gl vertex coord |
|
Emit a GL_LINES segment from start to end. |
|
Binds a buffer object to a specified binding point in the OpenGL context. |
|
get integer value |
|
Issue |
|
Select texture unit 0. |
|
Issue |
|
Issue |
|
Issue |
|
Issue |
|
Issue |
|
Generate mipmaps for the currently bound texture. |
|
Issue |
Package Contents
- picogl.backend.gl.api.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)[source]
gl bind buffer
- picogl.backend.gl.api.gl_generate_buffers(num: int = 1) Any[source]
Generate buffer object names.
A request for one name returns a Python
int.glGenBuffers(1)otherwise returns a length-1 array, whichglIsBufferdoes not accept as a buffer name.- Parameters:
num – How many names to generate
- Returns:
One buffer name, or the array of names when num is greater than 1
- picogl.backend.gl.api.gl_upload_float_buffer(data: list[float], buffer_target: picogl.backend.gl.enums.GLBufferTarget = GLBufferTarget.ARRAY) None[source]
Upload float vertex/attribute data to the bound buffer.
- picogl.backend.gl.api.gl_upload_ushort_buffer(data: list[int], buffer_target: picogl.backend.gl.enums.GLBufferTarget = GLBufferTarget.ELEMENT) None[source]
Upload unsigned-short index data to the bound element buffer.
- picogl.backend.gl.api.gl_disable_legacy_client_state(state: picogl.backend.gl.state.client.GLClientState) None[source]
gl disable client state
- picogl.backend.gl.api.gl_enable_legacy_client_state(state: picogl.backend.gl.state.client.GLClientState) None[source]
gl legacy client state
- picogl.backend.gl.api.gl_draw_arrays(index_count: int, mode: picogl.backend.gl.enums.GLDrawMode | int, first: int = 0) None[source]
Issue
glDrawArrayswith PicoGL draw-mode enums or raw gl constants.
- picogl.backend.gl.api.gl_draw_arrays_spec(spec: picogl.backend.modern.core.vertex.array.draw_spec.DrawSpec)[source]
gl draw arrays from spec
- picogl.backend.gl.api.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[source]
Issue
glDrawElements.pointer may be a client index array,
None(EBO bound), or omitted to use offset.
- picogl.backend.gl.api.gl_draw_elements_spec(spec: picogl.backend.modern.core.vertex.array.draw_spec.DrawSpec)[source]
gl draw elements from spec
- picogl.backend.gl.api.gl_bind_elements(index_buffer, size: int) None[source]
Bind ELEMENT buffer and draw triangles (ushort indices).
- picogl.backend.gl.api.gl_color_array_pointer(pointer: numpy.ndarray, size: int = 4, num_type: picogl.backend.gl.enums.GLNumeric = GLNumeric.FLOAT, stride: int = 0)[source]
gl color pointer for mesh binding.
- picogl.backend.gl.api.gl_color_pointer_from_spec(attr: picogl.gpu.buffers.attributes.AttributeSpec)[source]
gl color pointer
- picogl.backend.gl.api.gl_normal_array_pointer(pointer: numpy.ndarray, stride: int = 0, num_type: picogl.backend.gl.enums.GLNumeric = GLNumeric.FLOAT)[source]
gl normal pointer for mesh binding.
- picogl.backend.gl.api.gl_normal_pointer_from_spec(attr: picogl.gpu.buffers.attributes.AttributeSpec)[source]
gl normal pointer
- picogl.backend.gl.api.gl_texcoord_array_pointer(pointer: numpy.ndarray, size: int = 2, stride: int = 0, num_type: picogl.backend.gl.enums.GLNumeric = GLNumeric.FLOAT)[source]
gl texcoord pointer for mesh binding.
- picogl.backend.gl.api.gl_vertex_array_pointer(pointer: numpy.ndarray | int, size: int = 3, num_type: picogl.backend.gl.enums.GLNumeric = GLNumeric.FLOAT, stride: int = 0)[source]
gl vertex pointer for mesh binding.
- picogl.backend.gl.api.gl_vertex_pointer_from_spec(attr: picogl.gpu.buffers.attributes.AttributeSpec)[source]
gl legacy client state
- picogl.backend.gl.api.gl_bind_vertex_array(vao: int) None[source]
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.
- picogl.backend.gl.api.gl_bind_array_buffer(buffer, index: int = 0, size: int = 3, stride: int = 0) None[source]
Bind an ARRAY buffer and set its vertex attrib pointer.
- picogl.backend.gl.api.gl_bound_vertex_attrib_arrays(vertex_attrib_arrays: list[int]) collections.abc.Iterator[None][source]
Enable vertex attrib arrays for the block, then disable them.
- picogl.backend.gl.api.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: Any | None = None) None[source]
Issue
glVertexAttribPointer.offset may be a byte offset (
int),None, or actypes.c_void_p.
- picogl.backend.gl.api.gl_enable_vertex_array(location: int) Any[source]
gl_enable_vertex_array
- Parameters:
location – int
- picogl.backend.gl.api.gl_generate_vertex_array(num: int = 1) Any[source]
gl_generate_vertex_array
- Parameters:
num – int
- picogl.backend.gl.api.gl_normal_3f(x: float, y: float, z: float) None[source]
Set the current normal vector.
- picogl.backend.gl.api.gl_vertex_coord(coord: molib.pdb.coordinate.coordinate.Coordinate3D) None[source]
gl vertex coord
- picogl.backend.gl.api.gl_vertex_line(coord_end: molib.pdb.coordinate.coordinate.Coordinate3D, coord_start: molib.pdb.coordinate.coordinate.Coordinate3D) None[source]
Emit a GL_LINES segment from start to end.
- picogl.backend.gl.api.gl_bind_buffer(target: int, vbo_id: int | None)[source]
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_idint 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.
- picogl.backend.gl.api.gl_active_texture(texture: int | picogl.texture.gltexture.GLTexture) None[source]
Issue
glActiveTexture.
- picogl.backend.gl.api.gl_bind_texture(tex_id: int, target: picogl.texture.gltexture.GLTexture = GLTexture.TEXTURE_2D) None[source]
Issue
glBindTexture.
- picogl.backend.gl.api.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[source]
Issue
glCompressedTexImage2Dfor a 2D texture.PyOpenGL’s wrapped
glCompressedTexImage2DomitsimageSizeand derives it fromdata. Passing an explicit size as the 7th argument makes PyOpenGL treat that int as the data pointer and raisesNumberHandler/arrayByteCount.
- picogl.backend.gl.api.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[source]
Issue
glTexImage2D.
- picogl.backend.gl.api.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[source]
Issue
glTexImage3D.
- picogl.backend.gl.api.gl_generate_mipmap(target: picogl.texture.gltexture.GLTexture = GLTexture.TEXTURE_2D) None[source]
Generate mipmaps for the currently bound texture.
- picogl.backend.gl.api.gl_tex_parameter(target: int, pname: picogl.texture.gltexture.GLTexture, param: picogl.texture.gltexparam.GLTexParam | picogl.core.texture_clamp.GLTextureClamp) None[source]
Issue
glTexParameteri.