No matching definitions.

opengl/buffers

src/opengl/buffers.tur
defn

make-vao

(make-vao :int)

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 :int)

generate a Vertex Buffer Object.

Opaque :int VBO handle.

Since: v0.1.0

defn

make-ebo

(make-ebo :int)

generate an Element Buffer Object (index buffer).

Opaque :int EBO handle.

Since: v0.1.0

defn

bind-vao

(bind-vao [vao :int] :void)

make a VAO current (or unbind with 0).

vaoVAO handle from make-vao, or 0 to unbind
(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).

vboVBO 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).

eboEBO 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.

datapointer to vertex data (opaque :int from float-array or malloc)
sizebyte size of the data
usagedraw usage keyword: :static-draw | :dynamic-draw | :stream-draw
(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.

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] :void)

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 it.

vsymbol to bind the :int 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