Skip to content

mesh

FreeBodyEngine.graphics.gl44.mesh #

GL44Mesh(attributes, indices=None, primitive=None, index_type=None, usage=None) #

Bases: Mesh

The GL 4.4 implementation of Mesh: one VAO with one VBO per attribute (bound to sequential vertex attribute locations in attributes' dict order) plus an optional EBO for indexed drawing. Identical in mechanism to GLMesh (graphics/gl33/mesh.py) - core vertex array/buffer upload hasn't changed between GL 3.3 and 4.4.

Creates the VAO/VBOs/EBO (the EBO only if indices is given), picks the GL primitive enum matching primitive, and immediately uploads the given attribute/index data via upload().

ebo = glGenBuffers(1) if indices is not None else None instance-attribute #

vao = glGenVertexArrays(1) instance-attribute #

vbos = {} instance-attribute #

destroy() #

Deletes every VBO, the EBO (if any), and the VAO itself.

draw() #

Issues the draw call for this mesh's currently uploaded buffers: glDrawElements if it has an index buffer, otherwise glDrawArrays sized off the first attribute's vertex count (its raw element count divided by 3, so this assumes that attribute is 3-component - e.g. positions).

upload() #

Uploads every attribute in self.attributes to its own VBO and wires it to a sequential vertex attribute location (location 0, 1, 2, ... in dict iteration order - so the order attributes are passed in matters), then uploads self.indices to the EBO if present. Raises ValueError for an AttributeType this backend doesn't know how to map to a GL type/size (MAT3/MAT4/VEC5/VEC6/IVEC5/IVEC6).