opengl/buffers
src/opengl/buffers.tur
defn
make-vao
(make-vao :int)
generate a Vertex Array Object.
Returns
Opaque :int VAO handle (GLuint stored as int64).
Example
(let [vao (make-vao)] ...)
Since: v0.1.0
defn
make-vbo
(make-vbo :int)
generate a Vertex Buffer Object.
Returns
Opaque :int VBO handle.
Since: v0.1.0
defn
make-ebo
(make-ebo :int)
generate an Element Buffer Object (index buffer).
Returns
Opaque :int EBO handle.
Since: v0.1.0
defn
bind-vao
(bind-vao [vao :int] :void)
make a VAO current (or unbind with 0).
Parameters
| vao | VAO handle from make-vao, or 0 to unbind |
Example
(bind-vao vao) ... (bind-vao 0)
Since: v0.1.0
defn
bind-vbo
(bind-vbo [vbo :int] :void)
bind a VBO to GL_ARRAY_BUFFER (or unbind with 0).
Parameters
| vbo | VBO handle from make-vbo, or 0 to unbind |
Since: v0.1.0
defn
bind-ebo
(bind-ebo [ebo :int] :void)
bind an EBO to GL_ELEMENT_ARRAY_BUFFER (or unbind with 0).
Parameters
| ebo | EBO handle from make-ebo, or 0 to unbind |
Since: v0.1.0
defn
upload-vertices
(upload-vertices [data :int size :int usage :cstr] :void)
stream a float array into the currently-bound VBO.
Parameters
| data | pointer to vertex data (opaque :int from float-array or malloc) | |
| size | byte size of the data | |
| usage | draw usage keyword: :static-draw | :dynamic-draw | :stream-draw |
Example
(upload-vertices verts (* 9 4) ":static-draw")
Since: v0.1.0
defn
upload-indices
(upload-indices [data :int size :int usage :cstr] :void)
stream an integer index array into the currently-bound EBO.
Parameters
| data | pointer to index data (opaque :int) | |
| size | byte size of the data | |
| usage | draw usage keyword |
Example
(upload-indices idx-data (* 36 4) ":static-draw")
Since: v0.1.0
defn
vertex-attrib
(vertex-attrib [index :int components :int type :cstr normalized :bool stride :int offset :int] :void)
describe a vertex attribute pointer and enable it.
Parameters
| index | attribute location (matches layout(location=N) in GLSL) | |
| components | number of components per vertex (1-4) | |
| type | component type keyword: :float | :int | :uint | :byte | |
| normalized | true to normalise integer values to [-1,1] or [0,1] | |
| stride | byte distance between the start of consecutive vertices | |
| offset | byte offset of this attribute within the stride |
Example
;; attribute 0: xyz position (3 floats), tightly packed stride=12 (vertex-attrib 0 3 ":float" false 12 0) ;; attribute 1: uv coords (2 floats), interleaved after xyz, stride=20 (vertex-attrib 1 2 ":float" false 20 12)
Since: v0.1.0
defmacro
with-vao
(with-vao [v & body])
bind a new VAO for the duration of body, then unbind it.
Parameters
| v | symbol to bind the :int VAO handle | |
| body | one or more expressions executed with v in scope |
Example
(with-vao v
(bind-vbo vbo)
(upload-vertices data size ":static-draw")
(vertex-attrib 0 3 ":float" false 12 0))
Since: v0.1.0