EAGL.Buffer (eagl v0.1.0)
View SourceHelper functions for OpenGL buffer and vertex array object management. Provides convenient wrappers for common VAO/VBO/EBO operations.
Summary
Functions
Creates a VAO with VBO and EBO for indexed geometry. Returns {vao, vbo, ebo} tuple.
Creates a simple indexed VAO with position-only vertices (3 floats per vertex). Convenience wrapper for indexed geometry with positions only.
Creates a simple VAO with position-only vertices (3 floats per vertex). Convenience wrapper for the most common case.
Creates a VAO with a single VBO containing vertex data. Returns {vao, vbo} tuple.
Deletes a VAO and its associated VBO and EBO.
Deletes a VAO and its associated VBOs.
Converts a list of indices to binary format for OpenGL.
Converts a list of vertex floats to binary format for OpenGL.
Functions
Creates a VAO with VBO and EBO for indexed geometry. Returns {vao, vbo, ebo} tuple.
Parameters
- vertices: List of floats representing vertex data
- indices: List of integers representing vertex indices
- attribute_configs: List of attribute configurations Each config is {location, size, type, normalized, stride, offset}
Example
vertices = [0.5, 0.5, 0.0, 0.5, -0.5, 0.0, -0.5, -0.5, 0.0, -0.5, 0.5, 0.0]
indices = [0, 1, 3, 1, 2, 3]
{vao, vbo, ebo} = create_indexed_array(vertices, indices, [{0, 3, @gl_float, @gl_false, 0, 0}])
Creates a simple indexed VAO with position-only vertices (3 floats per vertex). Convenience wrapper for indexed geometry with positions only.
Example
vertices = [0.5, 0.5, 0.0, 0.5, -0.5, 0.0, -0.5, -0.5, 0.0, -0.5, 0.5, 0.0]
indices = [0, 1, 3, 1, 2, 3] # Two triangles forming a rectangle
{vao, vbo, ebo} = create_indexed_position_array(vertices, indices)
Creates a simple VAO with position-only vertices (3 floats per vertex). Convenience wrapper for the most common case.
Example
vertices = [-0.5, -0.5, 0.0, 0.5, -0.5, 0.0, 0.0, 0.5, 0.0]
{vao, vbo} = create_position_array(vertices)
Creates a VAO with a single VBO containing vertex data. Returns {vao, vbo} tuple.
Parameters
- vertices: List of floats representing vertex data
- attribute_configs: List of attribute configurations Each config is {location, size, type, normalized, stride, offset}
Example
vertices = [-0.5, -0.5, 0.0, 0.5, -0.5, 0.0, 0.0, 0.5, 0.0]
{vao, vbo} = create_vertex_array(vertices, [{0, 3, @gl_float, @gl_false, 0, 0}])
Deletes a VAO and its associated VBO and EBO.
@spec delete_vertex_array(integer(), [integer()]) :: :ok
@spec delete_vertex_array(integer(), integer()) :: :ok
Deletes a VAO and its associated VBOs.
Converts a list of indices to binary format for OpenGL.
Converts a list of vertex floats to binary format for OpenGL.