opengl/textures
src/opengl/textures.tur
defn
make-texture
(make-texture :int)
generate a GL texture object.
Returns
Opaque :int texture handle.
Example
(let [t (make-texture)] (bind-texture t) ...)
Since: v0.1.0
defn
bind-texture
(bind-texture [t :int] :void)
bind a 2D texture as the current GL_TEXTURE_2D target.
Parameters
| t | texture handle from make-texture, or 0 to unbind |
Example
(bind-texture t)
Since: v0.1.0
defn
upload-texture-rgba
(upload-texture-rgba [data :int w :int h :int] :void)
upload raw RGBA8 pixel data to the bound texture.
Parameters
| data | pointer to RGBA pixel data (4 bytes per pixel, row-major) | |
| w | image width in pixels | |
| h | image height in pixels |
Example
(upload-texture-rgba pixels 512 512)
Since: v0.1.0
defn
set-texture-wrap
(set-texture-wrap [s :cstr t :cstr] :void)
set the S and T wrap modes for the bound texture.
Parameters
| s | wrap mode for horizontal axis: | |
| :repeat | :clamp-to-edge | :mirrored-repeat | :clamp-to-border | ||
| t | wrap mode for vertical axis (same keywords) |
Example
(set-texture-wrap ":repeat" ":repeat")
Since: v0.1.0
defn
set-texture-filter
(set-texture-filter [min-filter :cstr mag-filter :cstr] :void)
set the minification and magnification filter modes.
Parameters
| min-filter | minification filter: | |
| :nearest | :linear | :nearest-mipmap-nearest | | ||
| :linear-mipmap-nearest | :nearest-mipmap-linear | | ||
| :linear-mipmap-linear | ||
| mag-filter | magnification filter: :nearest | :linear |
Example
(set-texture-filter ":linear-mipmap-linear" ":linear")
Since: v0.1.0
defn
generate-mipmaps
(generate-mipmaps :void)
auto-generate mipmaps for the currently-bound texture.
Example
(generate-mipmaps)
Since: v0.1.0
defn
active-texture
(active-texture [unit :int] :void)
select the active texture unit before binding.
Parameters
| unit | texture unit index (0-based; most hardware supports 0-15) |
Example
(active-texture 0) (bind-texture diffuse-tex) (set-uniform-int prog "diffuse" 0)
Since: v0.1.0