No matching definitions.

opengl/buffers

src/opengl/buffers.tur
defn

make-vao

(make-vao :)

generate a Vertex Array Object.

Opaque :int VAO handle (GLuint stored as int64).

(let [vao (make-vao)] ...)

Since: v0.1.0

defn

make-vbo

(make-vbo :)

generate a Vertex Buffer Object.

Opaque :int VBO handle.

Since: v0.1.0

defn

make-ebo

(make-ebo :)

generate an Element Buffer Object (index buffer).

Opaque :int EBO handle.

Since: v0.1.0

defn

bind-vao

(bind-vao [^borrow vao : Vao] :)

make a VAO current. Borrows the handle (use unbind-vao to clear).

vaoVAO handle from make-vao (borrowed, not consumed)
(bind-vao vao)
  ...
  (unbind-vao)

Since: v0.1.0

defn

bind-vbo

(bind-vbo [^borrow vbo : Vbo] :)

bind a VBO to GL_ARRAY_BUFFER. Borrows the handle.

vboVBO handle from make-vbo (borrowed, not consumed)

Since: v0.1.0

defn

bind-ebo

(bind-ebo [^borrow ebo : Ebo] :)

bind an EBO to GL_ELEMENT_ARRAY_BUFFER. Borrows the handle.

eboEBO handle from make-ebo (borrowed, not consumed)

Since: v0.1.0

defn

unbind-vao

(unbind-vao :)

clear the current VAO binding (glBindVertexArray(0)).

Since: v0.3.0

defn

unbind-vbo

(unbind-vbo :)

clear the GL_ARRAY_BUFFER binding.

Since: v0.3.0

defn

unbind-ebo

(unbind-ebo :)

clear the GL_ELEMENT_ARRAY_BUFFER binding.

Since: v0.3.0

defn

delete-vao

(delete-vao [vao : Vao] :)

delete a VAO (glDeleteVertexArrays), consuming the handle.

vaoVAO handle from make-vao (consumed)

Since: v0.3.0

defn

delete-vbo

(delete-vbo [vbo : Vbo] :)

delete a VBO (glDeleteBuffers), consuming the handle.

vboVBO handle from make-vbo (consumed)

Since: v0.3.0

defn

delete-ebo

(delete-ebo [ebo : Ebo] :)

delete an EBO (glDeleteBuffers), consuming the handle.

eboEBO handle from make-ebo (consumed)

Since: v0.3.0

defn

upload-vertices

(upload-vertices [data : int size : int usage : cstr] :)

stream a float array into the currently-bound VBO.

datapointer to packed vertex data; float-array-ptr on an
opengl/arrays FloatArray, or your own malloc'd block
sizebyte size of the data
usagedraw usage keyword: :static-draw | :dynamic-draw | :stream-draw
(with-float-array verts 9
    (float-array-set! verts 0 0.6)
    (upload-vertices (float-array-ptr verts)
                     (float-array-bytes verts) ":static-draw"))

Since: v0.1.0

defn

upload-indices

(upload-indices [data : int size : int usage : cstr] :)

stream an integer index array into the currently-bound EBO.

datapointer to index data (opaque :int)
sizebyte size of the data
usagedraw usage keyword
(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] :)

describe a vertex attribute pointer and enable it.

indexattribute location (matches layout(location=N) in GLSL)
componentsnumber of components per vertex (1-4)
typecomponent type keyword: :float | :int | :uint | :byte
normalizedtrue to normalise integer values to [-1,1] or [0,1]
stridebyte distance between the start of consecutive vertices
offsetbyte offset of this attribute within the stride
;; 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 and delete

vsymbol to bind the VAO handle
bodyone or more expressions executed with v in scope
(with-vao v
    (bind-vbo vbo)
    (upload-vertices data size ":static-draw")
    (vertex-attrib 0 3 ":float" false 12 0))

Since: v0.1.0