opengl/input
src/opengl/input.tur
defn
key-pressed?
(key-pressed? [w :int key :int] :bool)
return true on the first frame a key transitions to pressed.
Parameters
| w | window handle from make-window | |
| key | GLFW key code integer (e.g. 256 for Escape, 32 for Space) |
Returns
true on the frame the key is first pressed (GLFW_PRESS action).
Example
(key-pressed? w 256) ; Escape pressed this frame
Since: v0.1.0
defn
mouse-pos
(mouse-pos [w :int] :int)
return the current cursor position as a two-element float pair.
Parameters
| w | window handle from make-window |
Returns
Opaque :int handle to a heap-allocated {double x; double y;} struct. Access components with mouse-pos-x and mouse-pos-y.
Example
(let [pos (mouse-pos w)] ...)
Since: v0.1.0
defn
mouse-button-pressed?
(mouse-button-pressed? [w :int button :int] :bool)
return true while a mouse button is held down.
Parameters
| w | window handle from make-window | |
| button | button index: 0=left, 1=right, 2=middle |
Returns
true while the button is in the pressed state.
Example
(mouse-button-pressed? w 0) ; left button held
Since: v0.1.0
Internal definitions
mouse-pos-x-- extract the x component from a mouse-pos result.mouse-pos-y-- extract the y component from a mouse-pos result.