Hack to make it work with CCL
[cl-glfw.git] / lib / glfw.lisp
blobda5eb35fb6e4ee5553f442e3519c306d969898b1
1 (in-package #:cl-glfw)
3 (eval-when (:compile-toplevel :load-toplevel)
4 (defconstant +false+ 0)
5 (defconstant +true+ 1)
8 ;; Key and button state/action definitions
9 (defconstant +release+ 0)
10 (defconstant +press+ 1)
12 ;; Keyboard key definitions: 8-bit ISO-8859-1 (Latin 1) encoding is used
13 ;; for printable keys (such as A-Z, 0-9 etc), and values above 256
14 ;; represent special (non-printable) keys (e.g. F1, Page Up etc).
15 (defconstant +key-unknown+ -1)
16 (defconstant +key-space+ 32)
17 (defconstant +key-special+ 256)
18 (defconstant +key-esc+ (+ +key-special+ 1))
19 (defconstant +key-f1+ (+ +key-special+ 2))
20 (defconstant +key-f2+ (+ +key-special+ 3))
21 (defconstant +key-f3+ (+ +key-special+ 4))
22 (defconstant +key-f4+ (+ +key-special+ 5))
23 (defconstant +key-f5+ (+ +key-special+ 6))
24 (defconstant +key-f6+ (+ +key-special+ 7))
25 (defconstant +key-f7+ (+ +key-special+ 8))
26 (defconstant +key-f8+ (+ +key-special+ 9))
27 (defconstant +key-f9+ (+ +key-special+ 10))
28 (defconstant +key-f10+ (+ +key-special+ 11))
29 (defconstant +key-f11+ (+ +key-special+ 12))
30 (defconstant +key-f12+ (+ +key-special+ 13))
31 (defconstant +key-f13+ (+ +key-special+ 14))
32 (defconstant +key-f14+ (+ +key-special+ 15))
33 (defconstant +key-f15+ (+ +key-special+ 16))
34 (defconstant +key-f16+ (+ +key-special+ 17))
35 (defconstant +key-f17+ (+ +key-special+ 18))
36 (defconstant +key-f18+ (+ +key-special+ 19))
37 (defconstant +key-f19+ (+ +key-special+ 20))
38 (defconstant +key-f20+ (+ +key-special+ 21))
39 (defconstant +key-f21+ (+ +key-special+ 22))
40 (defconstant +key-f22+ (+ +key-special+ 23))
41 (defconstant +key-f23+ (+ +key-special+ 24))
42 (defconstant +key-f24+ (+ +key-special+ 25))
43 (defconstant +key-f25+ (+ +key-special+ 26))
44 (defconstant +key-up+ (+ +key-special+ 27))
45 (defconstant +key-down+ (+ +key-special+ 28))
46 (defconstant +key-left+ (+ +key-special+ 29))
47 (defconstant +key-right+ (+ +key-special+ 30))
48 (defconstant +key-lshift+ (+ +key-special+ 31))
49 (defconstant +key-rshift+ (+ +key-special+ 32))
50 (defconstant +key-lctrl+ (+ +key-special+ 33))
51 (defconstant +key-rctrl+ (+ +key-special+ 34))
52 (defconstant +key-lalt+ (+ +key-special+ 35))
53 (defconstant +key-ralt+ (+ +key-special+ 36))
54 (defconstant +key-tab+ (+ +key-special+ 37))
55 (defconstant +key-enter+ (+ +key-special+ 38))
56 (defconstant +key-backspace+ (+ +key-special+ 39))
57 (defconstant +key-insert+ (+ +key-special+ 40))
58 (defconstant +key-del+ (+ +key-special+ 41))
59 (defconstant +key-pageup+ (+ +key-special+ 42))
60 (defconstant +key-pagedown+ (+ +key-special+ 43))
61 (defconstant +key-home+ (+ +key-special+ 44))
62 (defconstant +key-end+ (+ +key-special+ 45))
63 (defconstant +key-kp-0+ (+ +key-special+ 46))
64 (defconstant +key-kp-1+ (+ +key-special+ 47))
65 (defconstant +key-kp-2+ (+ +key-special+ 48))
66 (defconstant +key-kp-3+ (+ +key-special+ 49))
67 (defconstant +key-kp-4+ (+ +key-special+ 50))
68 (defconstant +key-kp-5+ (+ +key-special+ 51))
69 (defconstant +key-kp-6+ (+ +key-special+ 52))
70 (defconstant +key-kp-7+ (+ +key-special+ 53))
71 (defconstant +key-kp-8+ (+ +key-special+ 54))
72 (defconstant +key-kp-9+ (+ +key-special+ 55))
73 (defconstant +key-kp-divide+ (+ +key-special+ 56))
74 (defconstant +key-kp-multiply+ (+ +key-special+ 57))
75 (defconstant +key-kp-subtract+ (+ +key-special+ 58))
76 (defconstant +key-kp-add+ (+ +key-special+ 59))
77 (defconstant +key-kp-decimal+ (+ +key-special+ 60))
78 (defconstant +key-kp-equal+ (+ +key-special+ 61))
79 (defconstant +key-kp-enter+ (+ +key-special+ 62))
80 (defconstant +key-last+ +key-kp-enter+)
82 ;; Mouse button definitions
83 (defconstant +mouse-button-1+ 0)
84 (defconstant +mouse-button-2+ 1)
85 (defconstant +mouse-button-3+ 2)
86 (defconstant +mouse-button-4+ 3)
87 (defconstant +mouse-button-5+ 4)
88 (defconstant +mouse-button-6+ 5)
89 (defconstant +mouse-button-7+ 6)
90 (defconstant +mouse-button-8+ 7)
91 (defconstant +mouse-button-last+ +mouse-button-8+)
93 ;; Mouse button aliases
94 (defconstant +mouse-button-left+ +mouse-button-1+)
95 (defconstant +mouse-button-right+ +mouse-button-2+)
96 (defconstant +mouse-button-middle+ +mouse-button-3+)
98 ;; Joystick identifiers
99 (defconstant +joystick-1+ 0)
100 (defconstant +joystick-2+ 1)
101 (defconstant +joystick-3+ 2)
102 (defconstant +joystick-4+ 3)
103 (defconstant +joystick-5+ 4)
104 (defconstant +joystick-6+ 5)
105 (defconstant +joystick-7+ 6)
106 (defconstant +joystick-8+ 7)
107 (defconstant +joystick-9+ 8)
108 (defconstant +joystick-10+ 9)
109 (defconstant +joystick-11+ 10)
110 (defconstant +joystick-12+ 11)
111 (defconstant +joystick-13+ 12)
112 (defconstant +joystick-14+ 13)
113 (defconstant +joystick-15+ 14)
114 (defconstant +joystick-16+ 15)
115 (defconstant +joystick-last+ +joystick-16+)
118 ;;========================================================================
119 ;; Other definitions
120 ;;========================================================================
122 ;; glfwOpenWindow modes
123 (defconstant +window+ #x00010001)
124 (defconstant +fullscreen+ #x00010002)
126 ;; glfwGetWindowParam tokens
127 (defconstant +opened+ #x00020001)
128 (defconstant +active+ #x00020002)
129 (defconstant +iconified+ #x00020003)
130 (defconstant +accelerated+ #x00020004)
131 (defconstant +red-bits+ #x00020005)
132 (defconstant +green-bits+ #x00020006)
133 (defconstant +blue-bits+ #x00020007)
134 (defconstant +alpha-bits+ #x00020008)
135 (defconstant +depth-bits+ #x00020009)
136 (defconstant +stencil-bits+ #x0002000a)
138 ;; The following constants are used for both glfwGetWindowParam
139 ;; and glfwOpenWindowHint
140 (defconstant +refresh-rate+ #x0002000b)
141 (defconstant +accum-red-bits+ #x0002000c)
142 (defconstant +accum-green-bits+ #x0002000d)
143 (defconstant +accum-blue-bits+ #x0002000e)
144 (defconstant +accum-alpha-bits+ #x0002000f)
145 (defconstant +aux-buffers+ #x00020010)
146 (defconstant +stereo+ #x00020011)
147 (defconstant +window-no-resize+ #x00020012)
148 (defconstant +fsaa-samples+ #x00020013)
150 ;; glfwEnable/glfwDisable tokens
151 (defconstant +mouse-cursor+ #x00030001)
152 (defconstant +sticky-keys+ #x00030002)
153 (defconstant +sticky-mouse-buttons+ #x00030003)
154 (defconstant +system-keys+ #x00030004)
155 (defconstant +key-repeat+ #x00030005)
156 (defconstant +auto-poll-events+ #x00030006)
158 ;; glfwWaitThread wait modes
159 (defconstant +wait+ #x00040001)
160 (defconstant +nowait+ #x00040002)
162 ;; glfwGetJoystickParam tokens
163 (defconstant +present+ #x00050001)
164 (defconstant +axes+ #x00050002)
165 (defconstant +buttons+ #x00050003)
167 ;; glfwReadImage/glfwLoadTexture2D flags
168 (defconstant +no-rescale-bit+ #x00000001) ; Only for glfwReadImage
169 (defconstant +origin-ul-bit+ #x00000002)
170 (defconstant +build-mipmaps-bit+ #x00000004) ; Only for glfwLoadTexture2D
171 (defconstant +alpha-map-bit+ #x00000008)
173 ;; Time spans longer than this (seconds) are considered to be infinity
174 (defconstant +infinity+ 100000d0))
176 (defparameter *was-init* nil
177 "True if we have already initialized.")
178 (declaim (type cl:boolean *was-init*))
180 (defparameter *init-hooks* nil
181 "A list of funcallable objects invoked just after initialization.")
182 (defparameter *terminate-hooks* nil
183 "A list of funcallable objects invoked just before termination.")
184 (declaim (type list *init-hooks* *terminate-hooks*))
186 (cffi:defcfun ("glfwInit" %init) boolean)
188 (defun init ()
189 "Return values
190 If the function succeeds, t is returned.
191 If the function fails, nil is returned.
193 The glfwInit function initializes GLFW. No other GLFW functions may be used before this function
194 has been called.
196 On successful initialization, the list of functions in *init-hooks* is called.
198 Notes
199 This function may take several seconds to complete on some systems, while on other systems it may
200 take only a fraction of a second to complete."
201 (when (%init)
202 (setf *was-init* t)
203 (mapc #'funcall *init-hooks*)
206 (cffi:defcfun ("glfwTerminate" %terminate) :void)
208 (defun terminate ()
209 "The function terminates GLFW. Among other things it closes the window, if it is opened, and kills any
210 running threads. This function must be called before a program exits.
212 Before termination, the list of functions in *terminate-hooks* is called.
214 (mapc #'funcall *terminate-hooks*)
215 (setf *was-init* nil)
216 (%terminate))
218 (defcfun+out+doc ("glfwGetVersion" get-version) :void ((:out major :int)
219 (:out minor :int)
220 (:out rev :int))
221 "Return values
222 The function returns the major and minor version numbers and the revision for the currently linked
223 GLFW library as a list (major minor rev).")
225 (defmacro with-init (&body forms)
226 "Call glfw:init, execute forms and clean-up with glfw:terminate once finished.
227 This makes a nice wrapper to an application higher-level form.
228 Signals an error on failure to initialize. Wrapped in a block named glfw:with-init."
229 `(if (glfw:init)
230 (unwind-protect
231 (block with-init ,@forms)
232 (glfw:terminate))
233 (error "Error initializing glfw.")))
235 (defcfun ("glfwOpenWindow" %open-window) boolean
236 (width :int) (height :int)
237 (redbits :int) (greenbits :int) (bluebits :int) (alphabits :int)
238 (depthbits :int) (stencilbits :int) (mode :int))
240 (declaim (inline open-window))
241 (defun open-window (&key (width 0) (height 0)
242 (redbits 0) (greenbits 0) (bluebits 0) (alphabits 0)
243 (depthbits 0) (stencilbits 0) (mode +window+))
244 "width
245 The width of the window. If width is zero, it will be calculated as width = 4/3 height, if height is
246 not zero. If both width and height are zero, then width will be set to 640.
247 height
248 The height of the window. If height is zero, it will be calculated as height = 3/4 width, if width is
249 not zero. If both width and height are zero, then height will be set to 480.
250 redbits, greenbits, bluebits
251 The number of bits to use for each color component of the color buffer (0 means default color
252 depth). For instance, setting redbits=5, greenbits=6, and bluebits=5 will generate a 16-bit color
253 buffer, if possible.
254 alphabits
255 The number of bits to use for the alpha buffer (0 means no alpha buffer).
256 depthbits
257 The number of bits to use for the depth buffer (0 means no depth buffer).
258 stencilbits
259 The number of bits to use for the stencil buffer (0 means no stencil buffer).
260 mode
261 Selects which type of OpenGL window to use. mode can be either +WINDOW+, which
262 will generate a normal desktop window, or +FULLSCREEN+ which will generate a
263 window which covers the entire screen. When +FULLSCREEN+ is selected, the video
264 mode will be changed to the resolution that closest matches the width and height parameters.
266 Return values
267 If the function succeeds, t is returned.
268 If the function fails, nil is returned.
270 Description
272 The function opens a window that best matches the parameters given to
273 the function. How well the resulting window matches the desired window
274 depends mostly on the available hardware and OpenGL drivers. In
275 general, selecting a fullscreen mode has better chances of generating
276 a close match than does a normal desktop window, since GLFW can freely
277 select from all the available video modes. A desktop window is
278 normally restricted to the video mode of the desktop.
280 Notes
282 For additional control of window properties, see glfw::OpenWindowHint.
283 In fullscreen mode the mouse cursor is hidden by default, and any system screensavers are prohibited
284 from starting. In windowed mode the mouse cursor is visible, and screensavers are allowed to start. To
285 change the visibility of the mouse cursor, use glfwEnable or glfwDisable with the argument
286 +MOUSE_CURSOR+
287 In order to determine the actual properties of an opened window, use glfw::GetWindowParam and
288 glfw::GetWindowSize (or glfw::SetWindowSizeCallback).
290 (%open-window width height redbits greenbits bluebits alphabits depthbits stencilbits mode))
294 (defcfun+doc ("glfwOpenWindowHint" open-window-hint) :void ((target :int) (hint :int))
295 "target
296 Can be any of the constants in the table 3.1.
297 hint
298 An integer giving the value of the corresponding target (see table 3.1).
300 Description
301 The function sets additional properties for a window that is to be opened. For a hint to be registered, the
302 function must be called before calling glfw::OpenWindow. When the glfw::OpenWindow function is
303 called, any hints that were registered with the glfw::OpenWindowHint function are used for setting the
304 corresponding window properties, and then all hints are reset to their default values.
306 Notes
307 In order to determine the actual properties of an opened window, use glfw::GetWindowParam (after the
308 window has been opened).
309 +STEREO+ is a hard constraint. If stereo rendering is requested, but no stereo rendering capable
310 pixel formats / visuals are available, glfw::OpenWindow will fail.
311 The +REFRESH_RATE+ property should be used with caution. Most systems have default values
312 for monitor refresh rates that are optimal for the specific system. Specifying the refresh rate can
313 override these settings, which can result in suboptimal operation. The monitor may be unable to display
314 the resulting video signal, or in the worst case it may even be damaged!
317 (defcfun+doc ("glfwCloseWindow" close-window) :void ()
318 "The function closes an opened window and destroys the associated OpenGL context.")
320 (defmacro with-open-window ((&key (title "cl-glfw window") (width 0) (height 0)
321 (redbits 0) (greenbits 0) (bluebits 0) (alphabits 0)
322 (depthbits 0) (stencilbits 0) (mode +window+))
323 &body forms)
324 "Wraps forms such that there is an open window for them to execute in and cleans up the
325 window afterwards. An error is signalled if there was an error opening the window.
326 Takes the same parameters as open-window, with the addition of 'title' which will
327 set the window title after opening.
328 Wrapped in a block named glfw:with-open-window."
329 `(if (%open-window ,width ,height ,redbits ,greenbits ,bluebits ,alphabits ,depthbits ,stencilbits ,mode)
330 (unwind-protect
331 (block with-open-window
332 (glfw:set-window-title ,title)
333 ,@forms)
334 (when (= +true+ (glfw:get-window-param glfw:+opened+))
335 (close-window)))
336 (error "Error initializing glfw window.")))
338 (defmacro with-init-window ((&key (title "cl-glfw window") (width 0) (height 0)
339 (redbits 0) (greenbits 0) (bluebits 0) (alphabits 0)
340 (depthbits 0) (stencilbits 0) (mode +window+))
341 &body forms)
342 "Wraps forms in with-init, with-open-window. Passes through the other arguments to open-window."
343 `(with-init
344 (with-open-window (:title ,title :width ,width :height ,height :redbits ,redbits :greenbits ,greenbits :bluebits ,bluebits :alphabits ,alphabits :depthbits ,depthbits :stencilbits ,stencilbits :mode ,mode)
345 ,@forms)))
347 (defmacro do-window ((&key (title "cl-glfw window") (width 0) (height 0)
348 (redbits 0) (greenbits 0) (bluebits 0) (alphabits 0)
349 (depthbits 0) (stencilbits 0) (mode +window+))
350 (&body setup-forms)
351 &body forms)
352 "High-level convenience macro for initializing glfw, opening a window (given the optional window parameters),
353 setting the title given,
354 running setup-forms and then running forms in a loop, with calls to swap-buffers after each loop iteration.
355 The loop is in a block named do-window [so can be exited by a call to (return-from glfw:do-window)].
356 If the window is closed, the loop is also exited."
357 `(with-init-window (:title ,title :width ,width :height ,height :redbits ,redbits :greenbits ,greenbits :bluebits ,bluebits :alphabits ,alphabits :depthbits ,depthbits :stencilbits ,stencilbits :mode ,mode)
358 ,@setup-forms
359 (loop named do-window do
360 ,@forms
361 (glfw:swap-buffers)
362 (unless (= +true+ (glfw:get-window-param glfw:+opened+))
363 (return-from do-window)))))
365 (defmacro define-callback-setter (c-name callback-prefix return-type (&body args) &key before-form after-form documentation)
366 (let* ((callback-name (intern (format nil "~A-CALLBACK" callback-prefix)))
367 (special-name (intern (format nil "*~S*" callback-name)))
368 (setter-name (intern (format nil "SET-~S" callback-name)))
369 (internal-setter-name (intern (format nil "%~S" setter-name))))
370 `(progn
371 (defparameter ,special-name nil)
372 (cffi:defcallback ,callback-name ,return-type ,args
373 (when ,special-name
374 (prog2
375 ,before-form
376 (funcall ,special-name ,@(mapcar #'car args))
377 ,after-form)))
378 (cffi:defcfun (,c-name ,internal-setter-name) :void (cbfun :pointer))
379 (defun ,setter-name (callback)
380 ,(format nil "GENERAL CL-GLFW CALLBACK NOTES
382 All callback setting functions can take either a pointer to a C function,
383 a function object, a function symbol, or nil to clear the callback function.
385 THIS CALLBACK FUNCTION
387 ~a" documentation)
388 (cl:cond
389 ((null callback)
390 (,internal-setter-name (cffi:null-pointer)))
391 ((symbolp callback)
392 (setf ,special-name callback)
393 (,internal-setter-name (cffi:callback ,callback-name)))
394 ((functionp callback)
395 (setf ,special-name callback)
396 (,internal-setter-name (cffi:callback ,callback-name)))
397 ((cffi:pointerp callback)
398 (,internal-setter-name callback))
399 (t (error "Not an acceptable callback. Must be foreign pointer, function object, function's symbol, or nil.")))))))
402 (define-callback-setter "glfwSetWindowCloseCallback" #:window-close :int ()
403 :documentation
405 Function that will be called when a user requests that the window should be
406 closed, typically by clicking the window close icon (e.g. the cross in the upper right corner of a
407 window under Microsoft Windows). The function should have the following type:
408 (function () integer)
410 The return value of the callback function indicates whether or not the window close action should continue. If the function returns
411 gl:+true+, the window will be closed. If the function returns gl:+false+, the window will not
412 be closed. If you give a CFFI callback returning glfw:boolean, you can use t and nil as return types.
414 Notes
415 Window close events are recorded continuously, but only reported when glfwPollEvents,
416 glfwWaitEvents or glfwSwapBuffers is called.
417 The OpenGL context is still valid when this function is called.
418 Note that the window close callback function is not called when glfwCloseWindow is called, but only
419 when the close request comes from the window manager.
420 Do not call glfwCloseWindow from a window close callback function. Close the window by returning
421 gl:+true+ from the function.
425 (defcfun+doc ("glfwSetWindowTitle" set-window-title) :void ((title :string))
426 "Parameters
427 title
428 Pointer to a null terminated ISO 8859-1 (8-bit Latin 1) string that holds the title of the window.
430 Description
431 The function changes the title of the opened window.
433 Notes
434 The title property of a window is often used in situations other
435 than for the window title, such as the title of an application icon
436 when it is in iconified state.")
438 (defcfun+doc ("glfwSetWindowSize" set-window-size) :void ((width :int) (height :int))
439 "Parameters
440 width
441 Width of the window.
442 height
443 Height of the window.
444 Return values
445 none
446 Description
448 The function changes the size of an opened window. The width and
449 height parameters denote the size of the client area of the
450 window (i.e. excluding any window borders and decorations). If the
451 window is in fullscreen mode, the video mode will be changed to a
452 resolution that closest matches the width and height parameters (the
453 number of color bits will not be changed).
455 Notes
457 The OpenGL context is guaranteed to be preserved after calling glfwSetWindowSize, even if the
458 video mode is changed.
461 (defcfun+doc ("glfwSetWindowPos" set-window-pos) :void ((x :int) (y :int))
462 "Parameters
464 Horizontal position of the window, relative to the upper left corner of the desktop.
466 Vertical position of the window, relative to the upper left corner of the desktop.
467 Return values
468 none
469 Description
470 The function changes the position of an opened window. It does not have any effect on a fullscreen
471 window.
474 (defcfun ("glfwGetWindowSize" %get-window-size) :void (width :pointer) (height :pointer))
475 (defun get-window-size ()
476 "The function is used for determining the size of an opened window. The returned values are dimensions
477 of the client area of the window (i.e. excluding any window borders and decorations).
478 (list width height)"
479 (cffi:with-foreign-objects ((width :int)
480 (height :int))
481 (%get-window-size width height)
482 (list (mem-ref width :int)
483 (mem-ref height :int))))
485 (define-callback-setter "glfwSetWindowSizeCallback" #:window-size :void ((width :int) (height :int))
486 :documentation
488 Function that will be called every time the window size changes. The
489 function should takes the arguments (width height) giving the new width and height of the window client area.
491 A window has to be opened for this function to have any effect.
492 Notes
493 Window size changes are recorded continuously, but only reported when glfwPollEvents,
494 glfwWaitEvents or glfwSwapBuffers is called. ")
496 (defcfun+doc ("glfwIconifyWindow" iconify-window) :void ()
497 "Iconify a window. If the window is in fullscreen mode, then the desktop video mode will be restored.")
499 (defcfun+doc ("glfwRestoreWindow" restore-window) :void ()
500 "Restore an iconified window. If the window that is restored is in fullscreen mode, then the fullscreen
501 video mode will be restored.")
503 (defcfun+doc ("glfwGetWindowParam" get-window-param) :int ((param :int))
504 "Parameters
505 param
506 A token selecting which parameter the function should return (see table 3.2).
508 Return values
510 The function returns different parameters depending on the value of
511 param. Table 3.2 lists valid param values, and their corresponding
512 return values.
514 Description
515 The function is used for acquiring various properties of an opened window.
517 Notes: GLFW_ACCELERATED is only supported under Windows. Other systems
518 will always return GL_TRUE. Under Windows, GLFW_ACCELERATED means that
519 the OpenGL renderer is a 3rd party renderer, rather than the fallback
520 Microsoft software OpenGL renderer. In other words, it is not a real
521 guarantee that the OpenGL renderer is actually hardware accelerated.
524 (defcfun+doc ("glfwSwapBuffers" swap-buffers) :void ()
525 "The function swaps the back and front color buffers of the window. If +AUTO_POLL_EVENTS+
526 is enabled (which is the default), glfwPollEvents is called before swapping the front and back buffers.")
529 (defcfun+doc ("glfwSwapInterval" swap-interval) :void ((interval :int))
530 "Parameters
531 interval
532 Minimum number of monitor vertical retraces between each buffer swap performed by
533 glfwSwapBuffers. If interval is zero, buffer swaps will not be synchronized to the vertical
534 refresh of the monitor (also known as VSync off).
536 Description
538 The function selects the minimum number of monitor vertical retraces
539 that should occur between two buffer swaps. If the selected swap
540 interval is one, the rate of buffer swaps will never be higher than
541 the vertical refresh rate of the monitor. If the selected swap
542 interval is zero, the rate of buffer swaps is only limited by the
543 speed of the software and the hardware.
545 Notes
547 This function will only have an effect on hardware and drivers that
548 support user selection of the swap interval. ")
551 (define-callback-setter "glfwSetWindowRefreshCallback" #:window-refresh :void ()
552 :documentation
554 Function that will be called when the window client area needs to be
555 refreshed. The function takes no arguments and returns nothing (void).
557 Description
559 The function selects which function to be called upon a window refresh
560 event, which occurs when any part of the window client area has been
561 damaged, and needs to be repainted (for instance, if a part of the
562 window that was previously occluded by another window has become
563 visible). A window has to be opened for this function to have any
564 effect.
566 Notes
567 Window refresh events are recorded continuously, but only reported when glfwPollEvents,
568 glfwWaitEvents or glfwSwapBuffers is called.
571 (defcstruct vidmode
572 (width :int)
573 (height :int)
574 (redbits :int)
575 (bluebits :int)
576 (greenbits :int))
578 (defcfun ("glfwGetVideoModes" %get-video-modes) :int (list :pointer) (maxcount :int))
580 (defun get-video-modes (maxcount)
581 "Parameters
582 maxcount
583 Maximum number of video modes that list vector can hold.
585 Return values
586 The function returns the number of detected video modes (this number will never exceed maxcount).
587 The list vector is filled out with the video modes that are supported by the system.
589 Description
590 The function returns a list of supported video modes. Each video mode is represented by a
591 list of the form:
592 (width height redbits greenbits bluebits)
594 Notes
595 The returned list is sorted, first by color depth (RedBits + GreenBits + BlueBits), and then by
596 resolution (Width * Height), with the lowest resolution, fewest bits per pixel mode first. "
597 (declare (optimize (debug 3)))
598 (with-foreign-object (list 'vidmode maxcount)
599 (let ((count (%get-video-modes list maxcount)))
600 (loop for i below count
601 collecting
602 (let ((mode (cffi:mem-aref list 'vidmode i)))
603 (list (foreign-slot-value mode 'vidmode 'width)
604 (foreign-slot-value mode 'vidmode 'height)
605 (foreign-slot-value mode 'vidmode 'redbits)
606 (foreign-slot-value mode 'vidmode 'greenbits)
607 (foreign-slot-value mode 'vidmode 'bluebits)))))))
609 (defcfun ("glfwGetDesktopMode" %get-desktop-mode) :void (mode :pointer))
610 (defun get-desktop-mode ()
611 "Parameters
612 mode
613 Pointer to a GLFWvidmode structure, which will be filled out by the function.
614 Return values
615 The GLFWvidmode structure pointed to by mode is filled out with the desktop video mode.
616 Description
617 The function returns the desktop video mode in a GLFWvidmode structure. See glfwGetVideoModes
618 for a definition of the GLFWvidmode structure.
619 Notes
620 The color depth of the desktop display is always reported as the number of bits for each individual color
621 component (red, green and blue), even if the desktop is not using an RGB or RGBA color format. For
622 instance, an indexed 256 color display may report RedBits = 3, GreenBits = 3 and BlueBits = 2, which
623 adds up to 8 bits in total.
624 The desktop video mode is the video mode used by the desktop, not the current video mode (which may
625 differ from the desktop video mode if the GLFW window is a fullscreen window).
627 (with-foreign-object (mode 'vidmode)
628 (%get-desktop-mode mode)
629 (list (foreign-slot-value mode 'vidmode 'width)
630 (foreign-slot-value mode 'vidmode 'height)
631 (foreign-slot-value mode 'vidmode 'redbits)
632 (foreign-slot-value mode 'vidmode 'greenbits)
633 (foreign-slot-value mode 'vidmode 'bluebits))))
635 (defcfun+doc ("glfwPollEvents" poll-events) :void ()
636 "Description
637 The function is used for polling for events, such as user input and window resize events. Upon calling
638 this function, all window states, keyboard states and mouse states are updated. If any related callback
639 functions are registered, these are called during the call to glfwPollEvents.
641 Notes
642 glfwPollEvents is called implicitly from glfwSwapBuffers if +AUTO_POLL_EVENTS+ is
643 enabled (default). Thus, if glfwSwapBuffers is called frequently, which is normally the case, there is
644 no need to call glfwPollEvents.
647 (defcfun+doc ("glfwWaitEvents" wait-events) :void ()
648 "Description
649 The function is used for waiting for events, such as user input and window resize events. Upon calling
650 this function, the calling thread will be put to sleep until any event appears in the event queue. When
651 events are ready, the events will be processed just as they are processed by glfwPollEvents.
652 If there are any events in the queue when the function is called, the function will behave exactly like
653 glfwPollEvents (i.e. process all messages and then return, without blocking the calling thread).
655 Notes
656 It is guaranteed that glfwWaitEvents will wake up on any event that can be processed by
657 glfw::PollEvents. However, glfwWaitEvents may wake up on events that are not processed or reported
658 by glfw::PollEvents too, and the function may behave differently on different systems. Do no make any
659 assumptions about when or why glfw::WaitEvents will return.
662 (defmacro key-int-to-symbol (key-form)
663 `(case ,key-form
664 ,@(sort
665 (loop for special-key in '("backspace" "del" "down" "end" "enter" "esc" "f1" "f10" "f11" "f12" "f13"
666 "f14" "f15" "f16" "f17" "f18" "f19" "f2" "f20" "f21" "f22" "f23" "f24" "f25"
667 "f3" "f4" "f5" "f6" "f7" "f8" "f9" "home" "insert" "kp-0" "kp-1" "kp-2" "kp-3"
668 "kp-4" "kp-5" "kp-6" "kp-7" "kp-8" "kp-9" "kp-add" "kp-decimal" "kp-divide"
669 "kp-enter" "kp-equal" "kp-multiply" "kp-subtract" "lalt" "lctrl" "left"
670 "lshift" "pagedown" "pageup" "ralt" "rctrl" "right" "rshift"
671 "special" "tab" "unknown" "up")
672 collect
673 `(,(symbol-value (find-symbol (string-upcase (format nil "+key-~a+" special-key)) (find-package '#:glfw)))
674 ,(intern (string-upcase special-key) (find-package '#:keyword))))
675 #'(lambda (a b) (< (car a) (car b))))))
678 (defun lispify-key (key-int)
679 "Convert key-int from GLFW's integer representation to lisp characters if from 0 to 255, or keywords, if not within 0-255 inclusive."
680 (if (and (>= key-int 0) (< key-int 256))
681 (code-char key-int)
682 (key-int-to-symbol key-int)))
685 (defcfun+doc ("glfwGetKey" get-key) :int ((key :int))
686 "Parameters
688 A keyboard key identifier, which can be either an uppercase printable ISO 8859-1 (Latin 1)
689 character (e.g. 'A', '3' or '.'), or a special key identifier. Table 3.3 lists valid special key
690 identifiers.
691 Return values
692 The function returns +PRESS+ if the key is held down, or +RELEASE+ if the key is not
693 held down.
695 Description
696 The function queries the current state of a specific keyboard key. The physical location of each key
697 depends on the system keyboard layout setting.
699 Notes
700 The constant +KEY_SPACE+ is equal to 32, which is the ISO 8859-1 code for space.
701 Not all key codes are supported on all systems. Also, while some keys are available on some keyboard
702 layouts, they may not be available on other keyboard layouts.
703 For systems that do not distinguish between left and right versions of modifier keys (shift, alt and
704 control), the left version is used (e.g. +KEY_LSHIFT+)
705 A window must be opened for the function to have any effect, and glfw::PollEvents, glfw::WaitEvents or
706 glfw::SwapBuffers must be called before any keyboard events are recorded and reported by
707 glfw::GetKey.
711 (defun lispify-mouse-button (button-int)
712 "Convert button-int from GLFW's integer representation to a lisp keyword."
713 (case button-int
714 (#.glfw:+mouse-button-left+ :left)
715 (#.glfw:+mouse-button-middle+ :middle)
716 (#.glfw:+mouse-button-right+ :right)
717 (#.glfw:+mouse-button-4+ :button-4)
718 (#.glfw:+mouse-button-5+ :button-5)
719 (#.glfw:+mouse-button-6+ :button-6)
720 (#.glfw:+mouse-button-7+ :button-7)
721 (#.glfw:+mouse-button-8+ :button-8)))
724 (defcfun+doc ("glfwGetMouseButton" get-mouse-button) :int ((button :int))
725 "Parameters
726 button
727 A mouse button identifier, which can be one of the mouse button identifiers listed in table 3.4.
728 Return values
729 The function returns +PRESS+ if the mouse button is held down, or +RELEASE+ if the
730 mouse button is not held down.
731 Description
732 The function queries the current state of a specific mouse button.
733 Notes
734 A window must be opened for the function to have any effect, and glfw::PollEvents, glfw::WaitEvents or
735 glfw::SwapBuffers must be called before any mouse button events are recorded and reported by
736 glfw::GetMouseButton.
737 +MOUSE_BUTTON_LEFT+ is equal to +MOUSE_BUTTON_1+
738 +MOUSE_BUTTON_RIGHT+ is equal to +MOUSE_BUTTON_2+
739 +MOUSE_BUTTON_MIDDLE+ is equal to +MOUSE_BUTTON_3+
743 (defcfun+out+doc ("glfwGetMousePos" get-mouse-pos) :void ((:out xpos :int) (:out ypos :int))
744 "Return values
745 The function returns the current mouse position in xpos and ypos.
747 Description
748 The function returns the current mouse position. If the cursor is not hidden, the mouse position is the
749 cursor position, relative to the upper left corner of the window and limited to the client area of the
750 window. If the cursor is hidden, the mouse position is a virtual absolute position, not limited to any
751 boundaries except to those implied by the maximum number that can be represented by a signed integer
752 (normally -2147483648 to +2147483647).
754 Notes
755 A window must be opened for the function to have any effect, and glfw::PollEvents, glfw::WaitEvents or
756 glfw::SwapBuffers must be called before any mouse movements are recorded and reported by
757 glfw::GetMousePos.
761 (defcfun+doc ("glfwSetMousePos" set-mouse-pos) :void ((xpos :int) (ypos :int))
762 "Parameters
763 xpos
764 Horizontal position of the mouse.
765 ypos
766 Vertical position of the mouse.
768 Description
769 The function changes the position of the mouse. If the cursor is visible (not disabled), the cursor will be
770 moved to the specified position, relative to the upper left corner of the window client area. If the cursor
771 is hidden (disabled), only the mouse position that is reported by GLFW is changed.
774 (defcfun+doc ("glfwGetMouseWheel" get-mouse-wheel) :int ()
775 "Return values
776 The function returns the current mouse wheel position.
777 Description
778 The function returns the current mouse wheel position. The mouse wheel can be thought of as a third
779 mouse axis, which is available as a separate wheel or up/down stick on some mice.
780 Notes
781 A window must be opened for the function to have any effect, and glfw::PollEvents, glfw::WaitEvents or
782 glfw::SwapBuffers must be called before any mouse wheel movements are recorded and reported by
783 glfw::GetMouseWheel.
786 (defcfun+doc ("glfwSetMouseWheel" set-mouse-wheel) :void ((pos :int))
787 "Parameters
789 Position of the mouse wheel.
790 Description
791 The function changes the position of the mouse wheel.
795 (define-callback-setter "glfwSetKeyCallback" #:key :void ((key :int) (action :int))
796 :before-form (setf key (lispify-key key))
797 :documentation
799 Function that will be called every time a key is pressed or released.
800 Function should take the arguments (key action), where key is either a character,
801 if the key pressed was a member of iso-8859-1, or a keyword representing the key pressed if not.
802 See the GLFW manual, table 3.3 for special key identifiers. Action is either glfw:+press+ or
803 glfw:+release+. Use set-char-callback instead if you want to read just characters.
805 Description
806 The function selects which function to be called upon a keyboard key event. The callback function is
807 called every time the state of a single key is changed (from released to pressed or vice versa). The
808 reported keys are unaffected by any modifiers (such as shift or alt).
809 A window has to be opened for this function to have any effect.
811 Notes
812 Keyboard events are recorded continuously, but only reported when glfw::PollEvents, glfw::WaitEvents
813 or glfw::SwapBuffers is called.
815 (define-callback-setter "glfwSetCharCallback" #:char :void ((character :int) (action :int))
816 :before-form (setf character (code-char character))
817 :documentation
819 Function that will be called every time a printable character is generated by
820 the keyboard. The function should take the arguments (character action)
821 where character is a lisp character and action is either glfw:+press+ or glfw:+release+.
823 NB this makes the presumption that your lisp implementation will use Unicode for code-char.
825 Description
826 The function selects which function to be called upon a keyboard character event. The callback function
827 is called every time a key that results in a printable Unicode character is pressed or released. Characters
828 are affected by modifiers (such as shift or alt).
829 A window has to be opened for this function to have any effect.
831 Notes
832 Character events are recorded continuously, but only reported when glfw::PollEvents, glfw::WaitEvents
833 or glfw::SwapBuffers is called.
834 Control characters, such as tab and carriage return, are not reported to the character callback function,
835 since they are not part of the Unicode character set. Use the key callback function for such events (see
836 glfw::SetKeyCallback).
837 The Unicode character set supports character codes above 255, so never cast a Unicode character to an
838 eight bit data type (e.g. the C language char type) without first checking that the character code is less
839 than 256. Also note that Unicode character codes 0 to 255 are equal to ISO 8859-1 (Latin 1).
842 (define-callback-setter "glfwSetMouseButtonCallback" #:mouse-button :void ((button :int) (action :int))
843 :before-form (setf button (lispify-mouse-button button))
844 :documentation
846 Function that will be called every time a mouse button is pressed or released.
847 The function takes the arguments (button action), where button is a keyword symbol as returned by
848 lispify-mouse-button and action is either glfw:+press+ or glfw:+release+.
850 Description
851 The function selects which function to be called upon a mouse button event.
852 A window has to be opened for this function to have any effect.
854 Notes
855 Mouse button events are recorded continuously, but only reported when glfw::PollEvents,
856 glfw::WaitEvents or glfw::SwapBuffers is called.
857 +MOUSE_BUTTON_LEFT+ is equal to +MOUSE_BUTTON_1+
858 +MOUSE_BUTTON_RIGHT+ is equal to +MOUSE_BUTTON_2+
859 +MOUSE_BUTTON_MIDDLE+ is equal to +MOUSE_BUTTON_3+
861 (define-callback-setter "glfwSetMousePosCallback" #:mouse-pos :void ((x :int) (y :int))
862 :documentation
864 Function that will be called every time the mouse is moved.
865 The function takes the arguments (x y), where x and y are the current position of the mouse.
867 Description
868 The function selects which function to be called upon a mouse motion event.
869 A window has to be opened for this function to have any effect.
871 Notes
872 Mouse motion events are recorded continuously, but only reported when glfw::PollEvents,
873 glfw::WaitEvents or glfw::SwapBuffers is called.
876 (defparameter *mouse-wheel-cumulative* nil)
877 (define-callback-setter "glfwSetMouseWheelCallback" #:mouse-wheel :void ((pos :int))
878 :after-form (unless *mouse-wheel-cumulative* (glfw:set-mouse-wheel 0))
879 :documentation
881 Function that will be called every time the mouse wheel is moved.
882 The function takes one argument: the position of the mouse wheel.
883 This DIFFERS FROM GLFW's DEFAULT behaviour in that the position is
884 reset after every call to this function, effectively giving the delta.
885 As most programs are only interested in the delta anyway, this is thought
886 to save others recording the state of it again.
887 If you wish to have the original GLFW behaviour, set cl-glfw:*mouse-wheel-cumulative* to t.
889 Description
890 The function selects which function to be called upon a mouse wheel event.
891 A window has to be opened for this function to have any effect.
892 Notes
893 Mouse wheel events are recorded continuously, but only reported when glfw::PollEvents,
894 glfw::WaitEvents or glfw::SwapBuffers is called.
897 (defcfun+doc ("glfwGetJoystickParam" get-joystick-param) :int ((joy :int) (param :int))
898 "Parameters
900 A joystick identifier, which should be +JOYSTICK_n+ where n is in the range 1 to 16.
901 param
902 A token selecting which parameter the function should return (see table 3.5).
903 Return values
904 The function returns different parameters depending on the value of param. Table 3.5 lists valid param
905 values, and their corresponding return values.
906 Description
907 The function is used for acquiring various properties of a joystick.
908 Notes
909 The joystick information is updated every time the function is called.
910 No window has to be opened for joystick information to be valid.
913 (defcfun ("glfwGetJoystickPos" %get-joystick-pos) :int (joy :int) (pos :pointer) (numaxes :int))
915 (defun get-joystick-pos (joy numaxes)
916 "Parameters
918 A joystick identifier, which should be +JOYSTICK_n+ where n is in the range 1 to 16.
919 numaxes
920 Specifies how many axes should be returned.
921 Return values
922 An list that will hold the positional values for all requested axes.
923 If the joystick is not supported or connected, the function will
924 return nil.
926 Description
927 The function queries the current position of one or more axes of a joystick. The positional values are
928 returned in an array, where the first element represents the first axis of the joystick (normally the X
929 axis). Each position is in the range -1.0 to 1.0. Where applicable, the positive direction of an axis is
930 right, forward or up, and the negative direction is left, back or down.
931 If numaxes exceeds the number of axes supported by the joystick, or if the joystick is not available, the
932 unused elements in the pos array will be set to 0.0 (zero).
934 Notes
935 The joystick state is updated every time the function is called, so there is no need to call glfw::PollEvents
936 or glfw::WaitEvents for joystick state to be updated.
937 Use glfw::GetJoystickParam to retrieve joystick capabilities, such as joystick availability and number of
938 supported axes.
939 No window has to be opened for joystick input to be valid.
941 (with-foreign-object (pos :float numaxes)
942 (let ((numaxes (%get-joystick-pos joy pos numaxes)))
943 (loop for i below numaxes collecting (mem-aref pos :float i)))))
946 (defcfun ("glfwGetJoystickButtons" %get-joystick-buttons) :int (joy :int) (buttons :pointer) (numbuttons :int))
947 (defun get-joystick-buttons (joy numbuttons)
948 "Parameters
950 A joystick identifier, which should be +JOYSTICK_n+ where n is in the range 1 to 16.
951 numbuttons
952 Specifies how many buttons should be returned.
953 Return values
954 A list that will hold the button states for all requested buttons.
955 The function returns the number of actually returned buttons. This is the minimum of numbuttons and
956 the number of buttons supported by the joystick. If the joystick is not supported or connected, the
957 function will return 0 (zero).
959 Description
960 The function queries the current state of one or more buttons of a joystick. The button states are
961 returned in an array, where the first element represents the first button of the joystick. Each state can be
962 either +PRESS+ or +RELEASE+
963 If numbuttons exceeds the number of buttons supported by the joystick, or if the joystick is not
964 available, the unused elements in the buttons array will be set to +RELEASE+
966 Notes
967 The joystick state is updated every time the function is called, so there is no need to call glfw::PollEvents
968 or glfw::WaitEvents for joystick state to be updated.
969 Use glfw::GetJoystickParam to retrieve joystick capabilities, such as joystick availability and number of
970 supported buttons.
971 No window has to be opened for joystick input to be valid.
973 (with-foreign-object (buttons :unsigned-char numbuttons)
974 (let ((numbuttons (%get-joystick-buttons joy buttons numbuttons)))
975 (loop for i below numbuttons collecting (mem-aref buttons :unsigned-char i)))))
978 (defcfun+doc ("glfwGetTime" get-time) :double ()
979 "Return values
980 The function returns the value of the high precision timer. The time is measured in seconds, and is
981 returned as a double precision floating point value.
983 Description
984 The function returns the state of a high precision timer. Unless the timer has been set by the
985 glfw::SetTime function, the time is measured as the number of seconds that have passed since glfw::Init
986 was called.
988 Notes
989 The resolution of the timer depends on which system the program is running on. The worst case
990 resolution is somewhere in the order of 10 ms, while for most systems the resolution should be better
991 than 1us.
994 (defcfun+doc ("glfwSetTime" set-time) :void ((time :double))
995 "Parameters
996 time
997 Time (in seconds) that the timer should be set to.
999 Description
1000 The function sets the current time of the high precision timer to the specified time. Subsequent calls to
1001 glfw::GetTime will be relative to this time. The time is given in seconds.
1004 (defcfun+doc ("glfwSleep" sleep) :void ((time :double))
1005 "Parameters
1006 time
1007 Time, in seconds, to sleep.
1009 Description
1010 The function puts the calling thread to sleep for the requested period of time. Only the calling thread is
1011 put to sleep. Other threads within the same process can still execute.
1013 Notes
1014 There is usually a system dependent minimum time for which it is possible to sleep. This time is
1015 generally in the range 1 ms to 20 ms, depending on thread sheduling time slot intervals etc. Using a
1016 shorter time as a parameter to glfw::Sleep can give one of two results: either the thread will sleep for the
1017 minimum possible sleep time, or the thread will not sleep at all (glfw::Sleep returns immediately). The
1018 latter should only happen when very short sleep times are specified, if at all. ")
1020 (defcstruct image
1021 (width :int)
1022 (height :int)
1023 (format :int)
1024 (bytes-per-pixel :int)
1025 (data :pointer))
1027 (defcfun+doc ("glfwReadImage" read-image) boolean
1028 ((name :string) (img image) (flags :int))
1029 "Parameters
1030 name
1031 A null terminated ISO 8859-1 string holding the name of the file that should be read.
1033 Pointer to a GLFWimage struct, which will hold the information about the loaded image (if the
1034 read was successful).
1035 flags
1036 Flags for controlling the image reading process. Valid flags are listed in table 3.6
1037 Return values
1038 The function returns t if the image was loaded successfully. Otherwise nil is
1039 returned.
1040 Description
1041 The function reads an image from the file specified by the parameter name and returns the image
1042 information and data in a GLFWimage structure, which has the following definition:
1044 typedef struct {
1045 int Width, Height; // Image dimensions
1046 int Format; // OpenGL pixel format
1047 int BytesPerPixel; // Number of bytes per pixel
1048 unsigned char *Data; // Pointer to pixel data
1049 } GLFWimage;
1051 Width and Height give the dimensions of the image. Format specifies an OpenGL pixel format,
1052 which can be GL_LUMINANCE or GL_ALPHA (for gray scale images), GL_RGB or GL_RGBA.
1053 BytesPerPixel specifies the number of bytes per pixel. Data is a pointer to the actual pixel data.
1055 By default the read image is rescaled to the nearest larger 2m ? 2n resolution using bilinear
1056 interpolation, if necessary, which is useful if the image is to be used as an OpenGL texture. This
1057 behavior can be disabled by setting the GLFW_NO_RESCALE_BIT flag.
1058 Unless the flag GLFW_ORIGIN_UL_BIT is set, the first pixel in img->Data is the lower left corner of
1059 the image. If the flag GLFW_ORIGIN_UL_BIT is set, however, the first pixel is the upper left corner.
1060 For single component images (i.e. gray scale), Format is set to GL_ALPHA if the flag
1062 +ALPHA_MAP_BIT+ flag is set, otherwise Format is set to GL_LUMINANCE.
1063 Notes
1064 glfw::ReadImage supports the Truevision Targa version 1 file format (.TGA). Supported pixel formats
1065 are: 8-bit gray scale, 8-bit paletted (24/32-bit color), 24-bit true color and 32-bit true color + alpha.
1066 Paletted images are translated into true color or true color + alpha pixel formats.
1067 Please note that OpenGL 1.0 does not support single component alpha maps, so do not use images
1068 with Format = GL_ALPHA directly as textures under OpenGL 1.0.
1071 (defcfun+doc ("glfwReadMemoryImage" read-memory-image) boolean
1072 ((data :pointer) (size :long) (img image) (flags :int))
1073 "Parameters
1074 data
1075 The memory buffer holding the contents of the file that should be read.
1076 size
1077 The size, in bytes, of the memory buffer.
1079 Pointer to a GLFWimage struct, which will hold the information about the loaded image (if the
1080 read was successful).
1081 flags
1082 Flags for controlling the image reading process. Valid flags are listed in table 3.6
1083 Return values
1084 The function returns t if the image was loaded successfully. Otherwise nil is
1085 returned.
1086 Description
1087 The function reads an image from the memory buffer specified by the parameter data and returns the
1088 image information and data in a GLFWimage structure, which has the following definition:
1090 typedef struct {
1091 int Width, Height; // Image dimensions
1092 int Format; // OpenGL pixel format
1093 int BytesPerPixel; // Number of bytes per pixel
1094 unsigned char *Data; // Pointer to pixel data
1095 } GLFWimage;
1097 Width and Height give the dimensions of the image. Format specifies an OpenGL pixel format,
1098 which can be GL_LUMINANCE or GL_ALPHA (for gray scale images), GL_RGB or GL_RGBA.
1099 BytesPerPixel specifies the number of bytes per pixel. Data is a pointer to the actual pixel data.
1101 By default the read image is rescaled to the nearest larger 2m ? 2n resolution using bilinear
1102 interpolation, if necessary, which is useful if the image is to be used as an OpenGL texture. This
1103 behavior can be disabled by setting the GLFW_NO_RESCALE_BIT flag.
1104 Unless the flag GLFW_ORIGIN_UL_BIT is set, the first pixel in img->Data is the lower left corner of
1105 the image. If the flag GLFW_ORIGIN_UL_BIT is set, however, the first pixel is the upper left corner.
1106 For single component images (i.e. gray scale), Format is set to GL_ALPHA if the flag
1107 +ALPHA_MAP_BIT+ flag is set, otherwise Format is set to GL_LUMINANCE.
1108 Notes
1109 glfw::ReadMemoryImage supports the Truevision Targa version 1 file format (.TGA). Supported pixel
1110 formats are: 8-bit gray scale, 8-bit paletted (24/32-bit color), 24-bit true color and 32-bit true color +
1111 alpha.
1112 Paletted images are translated into true color or true color + alpha pixel formats.
1113 Please note that OpenGL 1.0 does not support single component alpha maps, so do not use images
1114 with Format = GL_ALPHA directly as textures under OpenGL 1.0.
1117 (defcfun+doc ("glfwFreeImage" free-image) :void ((img image))
1118 "Parameters
1120 Pointer to a GLFWimage struct.
1121 Description
1122 The function frees any memory occupied by a loaded image, and clears all the fields of the GLFWimage
1123 struct. Any image that has been loaded by the glfw::ReadImage function should be deallocated using
1124 this function, once the image is not needed anymore. ")
1126 (defcfun+doc ("glfwLoadTexture2D" load-texture-2d) boolean ((name :string) (flags :int))
1127 "Parameters
1128 name
1129 An ISO 8859-1 string holding the name of the file that should be loaded.
1130 flags
1131 Flags for controlling the texture loading process. Valid flags are listed in table 3.7.
1132 Return values
1133 The function returns t if the texture was loaded successfully. Otherwise nil is
1134 returned.
1136 Description
1138 The function reads an image from the file specified by the parameter
1139 name and uploads the image to OpenGL texture memory (using the
1140 glTexImage2D function). If the GLFW_BUILD_MIPMAPS_BIT flag is set,
1141 all mipmap levels for the loaded texture are generated and uploaded to
1142 texture memory. Unless the flag +ORIGIN_UL_BIT+ is set, the origin of
1143 the texture is the lower left corner of the loaded image. If the flag
1144 +ORIGIN_UL_BIT+ is set, however, the first pixel is the upper left
1145 corner. For single component images (i.e. gray scale), the texture is
1146 uploaded as an alpha mask if the flag +ALPHA_MAP_BIT+ flag is set,
1147 otherwise it is uploaded as a luminance texture.
1149 Notes
1150 glfw::LoadTexture2D supports the Truevision Targa version 1 file format (.TGA). Supported pixel
1151 formats are: 8-bit gray scale, 8-bit paletted (24/32-bit color), 24-bit true color and 32-bit true color +
1152 alpha.
1153 Paletted images are translated into true color or true color + alpha pixel formats.
1154 The read texture is always rescaled to the nearest larger 2m ? 2n resolution using bilinear interpolation,
1155 if necessary, since OpenGL requires textures to have a 2m ? 2n resolution.
1156 If the GL_SGIS_generate_mipmap extension, which is usually hardware accelerated, is supported by
1157 the OpenGL implementation it will be used for mipmap generation. Otherwise the mipmaps will be
1158 generated by GLFW in software.
1160 Since OpenGL 1.0 does not support single component alpha maps, alpha map textures are converted
1161 to RGBA format under OpenGL 1.0 when the GLFW_ALPHA_MAP_BIT flag is set and the loaded
1162 texture is a single component texture. The red, green and blue components are set to 1.0.
1165 (defcfun+doc ("glfwLoadMemoryTexture2D" load-memory-texture-2d) boolean
1166 ((data :pointer) (size :long) (flags :int))
1167 "Parameters
1168 data
1169 The memory buffer holding the contents of the file that should be loaded.
1170 size
1171 The size, in bytes, of the memory buffer.
1172 flags
1173 Flags for controlling the texture loading process. Valid flags are listed in table 3.7.
1174 Return values
1175 The function returns t if the texture was loaded successfully. Otherwise nil is
1176 returned.
1178 Description
1179 The function reads an image from the memory buffer specified by the parameter data and uploads the
1180 image to OpenGL texture memory (using the glTexImage2D function).
1181 If the GLFW_BUILD_MIPMAPS_BIT flag is set, all mipmap levels for the loaded texture are
1182 generated and uploaded to texture memory.
1183 Unless the flag +ORIGIN_UL_BIT+ is set, the origin of the texture is the lower left corner of the
1184 loaded image. If the flag +ORIGIN_UL_BIT+ is set, however, the first pixel is the upper left
1185 corner.
1186 For single component images (i.e. gray scale), the texture is uploaded as an alpha mask if the flag
1187 +ALPHA_MAP_BIT+ flag is set, otherwise it is uploaded as a luminance texture.
1189 Notes
1190 glfw::LoadMemoryTexture2D supports the Truevision Targa version 1 file format (.TGA). Supported
1191 pixel formats are: 8-bit gray scale, 8-bit paletted (24/32-bit color), 24-bit true color and 32-bit true color
1192 + alpha.
1193 Paletted images are translated into true color or true color + alpha pixel formats.
1194 The read texture is always rescaled to the nearest larger 2m ? 2n resolution using bilinear interpolation,
1195 if necessary, since OpenGL requires textures to have a 2m ? 2n resolution.
1196 If the GL_SGIS_generate_mipmap extension, which is usually hardware accelerated, is supported by
1197 the OpenGL implementation it will be used for mipmap generation. Otherwise the mipmaps will be
1198 generated by GLFW in software.
1200 Since OpenGL 1.0 does not support single component alpha maps, alpha map textures are converted
1201 to RGBA format under OpenGL 1.0 when the GLFW_ALPHA_MAP_BIT flag is set and the loaded
1202 texture is a single component texture. The red, green and blue components are set to 1.0.
1206 (defcfun+doc ("glfwLoadTextureImage2D" load-texture-image-2d) boolean ((img image)
1207 (flags :int))
1208 "Parameters
1210 Pointer to a GLFWimage struct holding the information about the image to be loaded.
1211 flags
1212 Flags for controlling the texture loading process. Valid flags are listed in table 3.7.
1213 Return values
1214 The function returns t if the texture was loaded successfully. Otherwise nil is
1215 returned.
1217 Description
1218 The function uploads the image specified by the parameter img to OpenGL texture memory (using
1219 the glTexImage2D function).
1220 If the +BUILD_MIPMAPS_BIT+ flag is set, all mipmap levels for the loaded texture are
1221 generated and uploaded to texture memory.
1222 Unless the flag +ORIGIN_UL_BIT+ is set, the origin of the texture is the lower left corner of the
1223 loaded image. If the flag +ORIGIN_UL_BIT+ is set, however, the first pixel is the upper left
1224 corner.
1225 For single component images (i.e. gray scale), the texture is uploaded as an alpha mask if the flag
1226 +ALPHA_MAP_BIT+ flag is set, otherwise it is uploaded as a luminance texture.
1228 Notes
1229 glfw::LoadTextureImage2D supports the Truevision Targa version 1 file format (.TGA). Supported
1230 pixel formats are: 8-bit gray scale, 8-bit paletted (24/32-bit color), 24-bit true color and 32-bit true color
1231 + alpha.
1232 Paletted images are translated into true color or true color + alpha pixel formats.
1233 The read texture is always rescaled to the nearest larger 2m ? 2n resolution using bilinear interpolation,
1234 if necessary, since OpenGL requires textures to have a 2m ? 2n resolution.
1235 If the GL_SGIS_generate_mipmap extension, which is usually hardware accelerated, is supported by
1236 the OpenGL implementation it will be used for mipmap generation. Otherwise the mipmaps will be
1237 generated by GLFW in software.
1239 Since OpenGL 1.0 does not support single component alpha maps, alpha map textures are converted
1240 to RGBA format under OpenGL 1.0 when the GLFW_ALPHA_MAP_BIT flag is set and the loaded
1241 texture is a single component texture. The red, green and blue components are set to 1.0. ")
1244 (defcfun+doc ("glfwExtensionSupported" extension-supported) boolean ((extension :string))
1245 "Parameters
1246 extension
1247 A null terminated ISO 8859-1 string containing the name of an OpenGL extension.
1248 Return values
1249 The function returns t if the extension is supported. Otherwise it returns nil.
1250 Description
1251 The function does a string search in the list of supported OpenGL extensions to find if the specified
1252 extension is listed.
1253 Notes
1255 An OpenGL context must be created before this function can be called (i.e. an OpenGL window
1256 must have been opened with glfwOpenWindow).
1257 In addition to checking for OpenGL extensions, GLFW also checks for extensions in the operating
1258 system ?glue API?, such as WGL extensions under Windows and glX extensions under the X Window
1259 System.
1262 (defcfun+doc ("glfwGetProcAddress" get-proc-address) :pointer ((procname :string))
1263 "Parameters
1264 procname
1265 A null terminated ISO 8859-1 string containing the name of an OpenGL extension function.
1266 Return values
1267 The function returns the pointer to the specified OpenGL function if it is supported, otherwise
1268 NULL is returned.
1269 Description
1270 The function acquires the pointer to an OpenGL extension function. Some (but not all) OpenGL
1271 extensions define new API functions, which are usually not available through normal linking. It is
1272 therefore necessary to get access to those API functions at runtime.
1273 Notes
1275 An OpenGL context must be created before this function can be called (i.e. an OpenGL window
1276 must have been opened with glfwOpenWindow).
1277 Some systems do not support dynamic function pointer retrieval, in which case glfwGetProcAddress
1278 will always return NULL.
1281 (defcfun+out+doc ("glfwGetGLVersion" get-gl-version) :void ((:out major :int)
1282 (:out minor :int)
1283 (:out rev :int))
1284 "Return values
1285 The function returns the major and minor version numbers and the revision for the currently used
1286 OpenGL implementation as a list (major minor rev).
1288 Description
1289 The function returns the OpenGL implementation version. This is a convenient function that parses
1290 the version number information from the string returned by calling
1291 glGetString( GL_VERSION ). The OpenGL version information can be used to determine
1292 what functionality is supported by the used OpenGL implementation.
1294 Notes
1295 An OpenGL context must be created before this function can be called (i.e. an OpenGL window
1296 must have been opened with glfwOpenWindow). ")
1298 (defctype thread :int)
1299 (defctype threadfun :pointer)
1300 (defctype mutex :pointer)
1301 (defctype cond :pointer)
1303 (defcfun+doc ("glfwCreateThread" create-thread) thread ((fun threadfun) (arg :pointer) )
1304 "Parameters
1306 A pointer to a function that acts as the entry point for the new thread. The function should have
1307 the following C language prototype:
1308 void GLFWCALL functionname( void *arg );
1309 Where functionname is the name of the thread function, and arg is the user supplied argument
1310 (see below).
1312 An arbitrary argument for the thread. arg will be passed as the argument to the thread function
1313 pointed to by fun. For instance, arg can point to data that is to be processed by the thread.
1314 Return values
1315 The function returns a thread identification number if the thread was created successfully. This number
1316 is always positive. If the function fails, a negative number is returned.
1317 Description
1318 The function creates a new thread, which executes within the same address space as the calling process.
1319 The thread entry point is specified with the fun argument.
1320 Once the thread function fun returns, the thread dies.
1321 Notes
1322 Even if the function returns a positive thread ID, indicating that the thread was created successfully, the
1323 thread may be unable to execute, for instance if the thread start address is not a valid thread entry point.
1325 (defcfun+doc ("glfwDestroyThread" destroy-thread) :void ((id thread))
1326 "Parameters
1328 A thread identification handle, which is returned by glfw::CreateThread or glfw::GetThreadID.
1329 Description
1330 The function kills a running thread and removes it from the thread list.
1331 Notes
1332 This function is a very dangerous operation, which may interrupt a thread in the middle of an important
1333 operation, and its use is discouraged. You should always try to end a thread in a graceful way using
1334 thread communication, and use glfw::WaitThread in order to wait for the thread to die.
1336 (defcfun+doc ("glfwWaitThread" wait-thread) boolean ((id thread) (waitmode :int) )
1337 "Parameters
1339 A thread identification handle, which is returned by glfw::CreateThread or glfw::GetThreadID.
1340 waitmode
1341 Can be either +WAIT+ or +NOWAIT+
1342 Return values
1343 The function returns t if the specified thread died after the function was called, or the thread
1344 did not exist, in which case glfw::WaitThread will return immediately regardless of waitmode. The
1345 function returns nil if waitmode is +NOWAIT+ and the specified thread exists and is still
1346 running.
1348 (defcfun+doc ("glfwGetThreadID" get-thread-id) thread ()
1349 "Return values
1350 The function returns a thread identification handle for the calling thread.
1351 Description
1352 The function determines the thread ID for the calling thread. The ID is the same value as was returned
1353 by glfw::CreateThread when the thread was created.
1356 (defcfun+doc ("glfwCreateMutex" create-mutex) mutex ()
1357 "Return values
1358 The function returns a mutex handle, or NULL if the mutex could not be created.
1359 Description
1360 The function creates a mutex object, which can be used to control access to data that is shared between
1361 threads.
1363 (defcfun+doc ("glfwDestroyMutex" destroy-mutex) :void ((mutex mutex))
1364 "Parameters
1365 mutex
1366 A mutex object handle.
1367 Description
1368 The function destroys a mutex object. After a mutex object has been destroyed, it may no longer be
1369 used by any thread.
1371 (defcfun+doc ("glfwLockMutex" lock-mutex) :void ((mutex mutex))
1372 "Parameters
1373 mutex
1374 A mutex object handle.
1375 Description
1376 The function will acquire a lock on the selected mutex object. If the mutex is already locked by another
1377 thread, the function will block the calling thread until it is released by the locking thread. Once the
1378 function returns, the calling thread has an exclusive lock on the mutex. To release the mutex, call
1379 glfw::UnlockMutex.
1381 (defcfun+doc ("glfwUnlockMutex" unlock-mutex) :void ((mutex mutex))
1382 "Parameters
1383 mutex
1384 A mutex object handle.
1385 Description
1386 The function releases the lock of a locked mutex object.
1389 (defmacro with-lock-mutex (mutex &body forms)
1390 "Parameters
1391 mutex
1392 A mutex object handle.
1393 forms
1394 Body of code to execute
1395 Description
1396 This macro will acquire a lock on the selected mutex object using glfw::LockMutex and release it afterwards
1397 using glfw::UnlockMutex.
1398 So, forms will not execute until an exclusive lock is held.
1399 The lock is then released when the stack is unwound."
1400 (let ((smutex (gensym "MUTEX-")))
1401 `(let ((,smutex ,mutex))
1402 (glfw:lock-mutex ,smutex)
1403 (unwind-protect (progn ,@forms)
1404 (glfw:unlock-mutex ,smutex)))))
1406 (defcfun+doc ("glfwCreateCond" create-cond) cond ()
1407 "Return values
1408 The function returns a condition variable handle, or NULL if the condition variable could not be
1409 created.
1410 Description
1411 The function creates a condition variable object, which can be used to synchronize threads.
1413 (defcfun+doc ("glfwDestroyCond" destroy-cond) :void ((cond cond))
1414 "Parameters
1415 cond
1416 A condition variable object handle.
1417 Description
1418 The function destroys a condition variable object. After a condition variable object has been destroyed,
1419 it may no longer be used by any thread.
1421 (defcfun+doc ("glfwWaitCond" wait-cond) :void ((cond cond) (mutex mutex) (timeout :double))
1422 " arameters
1423 cond
1424 A condition variable object handle.
1425 mutex
1426 A mutex object handle.
1427 timeout
1428 Maximum time to wait for the condition variable. The parameter can either be a positive time (in
1429 seconds), or +INFINITY+
1430 Description
1431 The function atomically unlocks the mutex specified by mutex, and waits for the condition variable cond
1432 to be signaled. The thread execution is suspended and does not consume any CPU time until the
1433 condition variable is signaled or the amount of time specified by timeout has passed. If timeout is
1434 +INFINITY+ glfw::WaitCond will wait forever for cond to be signaled. Before returning to the
1435 calling thread, glfw::WaitCond automatically re-acquires the mutex.
1436 Notes
1437 The mutex specified by mutex must be locked by the calling thread before entrance to glfw::WaitCond.
1438 A condition variable must always be associated with a mutex, to avoid the race condition where a thread
1439 prepares to wait on a condition variable and another thread signals the condition just before the first
1440 thread actually waits on it.
1442 (defcfun+doc ("glfwSignalCond" signal-cond) :void ((cond cond))
1443 "Parameters
1444 cond
1445 A condition variable object handle.
1446 Description
1447 The function restarts one of the threads that are waiting on the condition variable cond. If no threads are
1448 waiting on cond, nothing happens. If several threads are waiting on cond, exactly one is restarted, but it
1449 is not specified which.
1450 Notes
1451 When several threads are waiting for the condition variable, which thread is started depends on
1452 operating system scheduling rules, and may vary from system to system and from time to time.
1454 (defcfun+doc ("glfwBroadcastCond" broadcast-cond) :void ((cond cond))
1455 "Parameters
1456 cond
1457 A condition variable object handle.
1458 Description
1459 The function restarts all the threads that are waiting on the condition variable cond. If no threads are
1460 waiting on cond, nothing happens.
1461 Notes
1462 When several threads are waiting for the condition variable, the order in which threads are started
1463 depends on operating system scheduling rules, and may vary from system to system and from time to
1464 time.
1467 (defcfun+doc ("glfwGetNumberOfProcessors" get-number-of-processors) :int ()
1468 "Return values
1469 The function returns the number of active processors in the system.
1470 Description
1471 The function determines the number of active processors in the system.
1472 Notes
1473 Systems with several logical processors per physical processor, also known as SMT (Symmetric Multi
1474 Threading) processors, will report the number of logical processors.
1476 (defcfun+doc ("glfwEnable" enable) :void ((token :int))
1477 "Parameters
1478 token
1479 A value specifying a feature to enable or disable. Valid tokens are listed in table 3.8.
1480 Return values
1481 none
1482 Description
1483 glfw::Enable is used to enable a certain feature, while glfw::Disable is used to disable it. Below follows a
1484 description of each feature.
1485 +AUTO_POLL_EVENTS+
1486 When +AUTO_POLL_EVENTS+ is enabled, glfw::PollEvents is automatically called each time
1487 that glfw::SwapBuffers is called.
1488 When +AUTO_POLL_EVENTS+ is disabled, calling glfw::SwapBuffers will not result in a call to
1489 glfw::PollEvents. This can be useful if glfw::SwapBuffers needs to be called from within a callback
1490 function, since calling glfw::PollEvents from a callback function is not allowed.
1491 +KEY_REPEAT+
1492 When +KEY_REPEAT+ is enabled, the key and character callback functions are called repeatedly
1493 when a key is held down long enough (according to the system key repeat configuration).
1494 When +KEY_REPEAT+ is disabled, the key and character callback functions are only called once
1495 when a key is pressed (and once when it is released).
1496 +MOUSE_CURSOR+
1497 When +MOUSE_CURSOR+ is enabled, the mouse cursor is visible, and mouse coordinates are
1498 relative to the upper left corner of the client area of the GLFW window. The coordinates are limited to
1499 the client area of the window.
1500 When +MOUSE_CURSOR+ is disabled, the mouse cursor is invisible, and mouse coordinates are
1501 not limited to the drawing area of the window. It is as if the mouse coordinates are recieved directly
1502 from the mouse, without being restricted or manipulated by the windowing system.
1503 +STICKY_KEYS+
1504 When +STICKY_KEYS+ is enabled, keys which are pressed will not be released until they are
1505 physically released and checked with glfw::GetKey. This behavior makes it possible to catch keys that
1506 were pressed and then released again between two calls to glfw::PollEvents, glfw::WaitEvents or
1507 glfw::SwapBuffers, which would otherwise have been reported as released. Care should be taken when
1508 using this mode, since keys that are not checked with glfw::GetKey will never be released. Note also that
1509 enabling +STICKY_KEYS+ does not affect the behavior of the keyboard callback functionality.
1510 When +STICKY_KEYS+ is disabled, the status of a key that is reported by glfw::GetKey is always
1511 the physical state of the key. Disabling +STICKY_KEYS+ also clears the sticky information for
1512 all keys.
1513 +STICKY_MOUSE_BUTTONS+
1514 When +STICKY_MOUSE_BUTTONS+ is enabled, mouse buttons that are pressed will not be
1515 released until they are physically released and checked with glfw::GetMouseButton. This behavior
1516 makes it possible to catch mouse buttons which were pressed and then released again between two calls
1517 to glfw::PollEvents, glfw::WaitEvents or glfw::SwapBuffers, which would otherwise have been reported
1518 as released. Care should be taken when using this mode, since mouse buttons that are not checked with
1519 glfw::GetMouseButton will never be released. Note also that enabling
1520 +STICKY_MOUSE_BUTTONS+ does not affect the behavior of the mouse button callback
1521 functionality.
1522 When +STICKY_MOUSE_BUTTONS+ is disabled, the status of a mouse button that is reported
1523 by glfw::GetMouseButton is always the physical state of the mouse button. Disabling
1524 +STICKY_MOUSE_BUTTONS+ also clears the sticky information for all mouse buttons.
1525 +SYSTEM_KEYS+
1526 When +SYSTEM_KEYS+ is enabled, pressing standard system key combinations, such as
1527 ALT+TAB under Windows, will give the normal behavior. Note that when ALT+TAB is issued under
1528 Windows in this mode so that the GLFW application is deselected when GLFW is operating in
1529 fullscreen mode, the GLFW application window will be minimized and the video mode will be set to
1530 the original desktop mode. When the GLFW application is re-selected, the video mode will be set to
1531 the GLFW video mode again.
1532 When +SYSTEM_KEYS+ is disabled, pressing standard system key combinations will have no
1533 effect, since those key combinations are blocked by GLFW. This mode can be useful in situations when
1534 the GLFW program must not be interrupted (normally for games in fullscreen mode).
1536 (defcfun+doc ("glfwDisable" disable) :void ((token :int))
1537 "Parameters
1538 token
1539 A value specifying a feature to enable or disable. Valid tokens are listed in table 3.8.
1540 Return values
1541 none
1542 Description
1543 glfw::Enable is used to enable a certain feature, while glfw::Disable is used to disable it. Below follows a
1544 description of each feature.
1545 +AUTO_POLL_EVENTS+
1546 When +AUTO_POLL_EVENTS+ is enabled, glfw::PollEvents is automatically called each time
1547 that glfw::SwapBuffers is called.
1548 When +AUTO_POLL_EVENTS+ is disabled, calling glfw::SwapBuffers will not result in a call to
1549 glfw::PollEvents. This can be useful if glfw::SwapBuffers needs to be called from within a callback
1550 function, since calling glfw::PollEvents from a callback function is not allowed.
1551 +KEY_REPEAT+
1552 When +KEY_REPEAT+ is enabled, the key and character callback functions are called repeatedly
1553 when a key is held down long enough (according to the system key repeat configuration).
1554 When +KEY_REPEAT+ is disabled, the key and character callback functions are only called once
1555 when a key is pressed (and once when it is released).
1556 +MOUSE_CURSOR+
1557 When +MOUSE_CURSOR+ is enabled, the mouse cursor is visible, and mouse coordinates are
1558 relative to the upper left corner of the client area of the GLFW window. The coordinates are limited to
1559 the client area of the window.
1560 When +MOUSE_CURSOR+ is disabled, the mouse cursor is invisible, and mouse coordinates are
1561 not limited to the drawing area of the window. It is as if the mouse coordinates are recieved directly
1562 from the mouse, without being restricted or manipulated by the windowing system.
1563 +STICKY_KEYS+
1564 When +STICKY_KEYS+ is enabled, keys which are pressed will not be released until they are
1565 physically released and checked with glfw::GetKey. This behavior makes it possible to catch keys that
1566 were pressed and then released again between two calls to glfw::PollEvents, glfw::WaitEvents or
1567 glfw::SwapBuffers, which would otherwise have been reported as released. Care should be taken when
1568 using this mode, since keys that are not checked with glfw::GetKey will never be released. Note also that
1569 enabling +STICKY_KEYS+ does not affect the behavior of the keyboard callback functionality.
1570 When +STICKY_KEYS+ is disabled, the status of a key that is reported by glfwGetKey is always
1571 the physical state of the key. Disabling +STICKY_KEYS+ also clears the sticky information for
1572 all keys.
1573 +STICKY_MOUSE_BUTTONS+
1574 When +STICKY_MOUSE_BUTTONS+ is enabled, mouse buttons that are pressed will not be
1575 released until they are physically released and checked with glfw::GetMouseButton. This behavior
1576 makes it possible to catch mouse buttons which were pressed and then released again between two calls
1577 to glfw::PollEvents, glfw::WaitEvents or glfw::SwapBuffers, which would otherwise have been reported
1578 as released. Care should be taken when using this mode, since mouse buttons that are not checked with
1579 glfw::GetMouseButton will never be released. Note also that enabling
1580 +STICKY_MOUSE_BUTTONS+ does not affect the behavior of the mouse button callback
1581 functionality.
1582 When +STICKY_MOUSE_BUTTONS+ is disabled, the status of a mouse button that is reported
1583 by glfwGetMouseButton is always the physical state of the mouse button. Disabling
1584 +STICKY_MOUSE_BUTTONS+ also clears the sticky information for all mouse buttons.
1585 +SYSTEM_KEYS+
1586 When +SYSTEM_KEYS+ is enabled, pressing standard system key combinations, such as
1587 ALT+TAB under Windows, will give the normal behavior. Note that when ALT+TAB is issued under
1588 Windows in this mode so that the GLFW application is deselected when GLFW is operating in
1589 fullscreen mode, the GLFW application window will be minimized and the video mode will be set to
1590 the original desktop mode. When the GLFW application is re-selected, the video mode will be set to
1591 the GLFW video mode again.
1592 When +SYSTEM_KEYS+ is disabled, pressing standard system key combinations will have no
1593 effect, since those key combinations are blocked by GLFW. This mode can be useful in situations when
1594 the GLFW program must not be interrupted (normally for games in fullscreen mode).