opengl/window
src/opengl/window.tur
defn
make-window
(make-window [width :int height :int title :cstr] :int)
open a GLFW window and initialise an OpenGL 3.3 Core context.
Parameters
| width | window width in pixels | |
| height | window height in pixels | |
| title | window title string |
Returns
Opaque :int window handle. Calls exit(1) on failure.
Example
(let [w (make-window 800 600 "My App")] ...)
Since: v0.1.0
defn
destroy-window
(destroy-window [w :int] :void)
destroy a GLFW window and terminate the GLFW runtime.
Parameters
| w | window handle returned by make-window |
Example
(destroy-window w)
Since: v0.1.0
defn
window-should-close?
(window-should-close? [w :int] :bool)
return true if the user requested window close.
Parameters
| w | window handle |
Returns
true if the close button was clicked or ESC was pressed.
Example
(while (not (window-should-close? w)) ...)
Since: v0.1.0
defn
poll-events
(poll-events :void)
process pending window and input events.
Example
(poll-events)
Since: v0.1.0
defn
swap-buffers
(swap-buffers [w :int] :void)
present the rendered frame to the screen.
Parameters
| w | window handle |
Example
(swap-buffers w)
Since: v0.1.0
defn
set-clear-color
(set-clear-color [r :float g :float b :float a :float] :void)
set the color used by clear.
Parameters
| r | red channel (0.0-1.0) | |
| g | green channel (0.0-1.0) | |
| b | blue channel (0.0-1.0) | |
| a | alpha channel (0.0-1.0) |
Example
(set-clear-color 0.1 0.1 0.1 1.0)
Since: v0.1.0
defn
clear
(clear :void)
clear the color and depth buffers.
Example
(clear)
Since: v0.1.0
defmacro
with-window
(with-window [w width height title & body])
open a window, execute body, then destroy the window.
Parameters
| w | symbol to bind the :int window handle | |
| width | window width in pixels | |
| height | window height in pixels | |
| title | window title string | |
| body | one or more expressions executed with w in scope |
Example
(with-window w 800 600 "Demo"
(set-clear-color 0.1 0.1 0.1 1.0)
(while (not (window-should-close? w))
(clear)
(swap-buffers w)
(poll-events)))
Since: v0.1.0