picogl.tests.test_vertex_array_object
Unit tests for the VertexArrayObject class in the PicoGL OpenGL backend.
This module contains a comprehensive suite of unit tests for verifying the correctness,
robustness, and interface of the picogl.backend.modern.core.vertex.array.object.VertexArrayObject
class, which manages OpenGL Vertex Array Objects (VAOs) in modern OpenGL rendering workflows.
The tests cover:
Object initialization with and without handle parameter
VAO binding/unbinding operations
VBO management and attribute configuration
EBO (Element Buffer Object) management
Layout descriptor configuration
Drawing operations with various modes
Buffer cleanup and memory management
Error handling and edge cases
- Dependencies:
unittest (standard library)
unittest.mock.MagicMock for OpenGL function mocking
numpy for test data
picogl.backend.modern.core.vertex.array.object.VertexArrayObject
picogl.buffers.attributes.LayoutDescriptor
To run the tests:
python -m unittest picogl.tests.test_vertex_array_object
Classes
VertexBuffer stand-in that skips GL construction for unit tests. |
|
Test cases for VertexArrayObject class. |
Module Contents
- class picogl.tests.test_vertex_array_object._StubVBO(handle=None)[source]
Bases:
picogl.backend.modern.core.vertex.base.VertexBufferVertexBuffer stand-in that skips GL construction for unit tests.
- unbind[source]
Release this buffer target.
glBindBuffer(target, 0)does not need the previous name. Raising whenglIsBufferis false aborts the draw that is leaving itswithblock, which is how a stale or array handle shows up asInvalid buffer handlefor atoms, ribbons, and selections.
- set_data[source]
Upload data to the GPU.
- Parameters:
data – NumPy array containing buffer data.
usage – gl usage hint (e.g., GL_STATIC_DRAW, GL_DYNAMIC_DRAW).
- set_vertex_attributes[source]
Set the vertex attribute pointer configuration.
- Parameters:
index – Attribute index in the VAO.
data – Optional data array to store alongside attribute info.
size – Number of components per vertex (1-4).
normalized – Whether values should be normalized.
stride – Byte offset between consecutive attributes.
offset – Byte offset of the first attribute.
dtype – gl data type (e.g., GL_FLOAT).
pointer – Offset pointer for glVertexAttribPointer.
- class picogl.tests.test_vertex_array_object.TestVertexArrayObject(methodName='runTest')[source]
Bases:
unittest.TestCaseTest cases for VertexArrayObject class.
- test_initialization_with_handle()[source]
Test VertexArrayObject initialization with provided handle.
- test_initialization_without_handle()[source]
Test VertexArrayObject initialization without handle (auto-generate).
- test_initialization_raises_error_when_no_context()[source]
Test that initialization raises error when OpenGL context is not ready.
- test_set_layout_empty_attributes()[source]
Test set_layout with an empty descriptor still configures the VAO.
- test_set_layout_skips_ebo_attribute()[source]
Element-buffer layout entries are not vertex attributes.
- test_draw_explicit_zero_count_is_noop()[source]
Explicit count=0 must not fall back to the EBO length.