2 (:use
#:cl
#:cffi
#:gl
)
3 (:shadow
#:sleep
#:+red-bits
+ #:+green-bits
+ #:+blue-bits
+
4 #:+alpha-bits
+ #:+stencil-bits
+ #:+depth-bits
+
5 #:+accum-red-bits
+ #:+accum-green-bits
+ #:+accum-blue-bits
+
6 #:+accum-alpha-bits
+ #:+aux-buffers
+ #:+stereo
+
10 #:+accelerated
+ #:+accum-alpha-bits
+ #:+accum-blue-bits
+ #:+accum-green-bits
+ #:+accum-red-bits
+ #:+active
+ #:+alpha-bits
+ #:+alpha-map-bit
+ #:+auto-poll-events
+ #:+aux-buffers
+ #:+axes
+ #:+blue-bits
+ #:+build-mipmaps-bit
+ #:+buttons
+ #:+depth-bits
+ #:+fsaa-samples
+ #:+fullscreen
+ #:+green-bits
+ #:+iconified
+ #:+infinity
+ #:+joystick-1
+ #:+joystick-10
+ #:+joystick-11
+ #:+joystick-12
+ #:+joystick-13
+ #:+joystick-14
+ #:+joystick-15
+ #:+joystick-16
+ #:+joystick-2
+ #:+joystick-3
+ #:+joystick-4
+ #:+joystick-5
+ #:+joystick-6
+ #:+joystick-7
+ #:+joystick-8
+ #:+joystick-9
+ #:+joystick-last
+ #:+key-backspace
+ #:+key-del
+ #:+key-down
+ #:+key-end
+ #:+key-enter
+ #:+key-esc
+ #:+key-f1
+ #:+key-f10
+ #:+key-f11
+ #:+key-f12
+ #:+key-f13
+ #:+key-f14
+ #:+key-f15
+ #:+key-f16
+ #:+key-f17
+ #:+key-f18
+ #:+key-f19
+ #:+key-f2
+ #:+key-f20
+ #:+key-f21
+ #:+key-f22
+ #:+key-f23
+ #:+key-f24
+ #:+key-f25
+ #:+key-f3
+ #:+key-f4
+ #:+key-f5
+ #:+key-f6
+ #:+key-f7
+ #:+key-f8
+ #:+key-f9
+ #:+key-home
+ #:+key-insert
+ #:+key-kp-0
+ #:+key-kp-1
+ #:+key-kp-2
+ #:+key-kp-3
+ #:+key-kp-4
+ #:+key-kp-5
+ #:+key-kp-6
+ #:+key-kp-7
+ #:+key-kp-8
+ #:+key-kp-9
+ #:+key-kp-add
+ #:+key-kp-decimal
+ #:+key-kp-divide
+ #:+key-kp-enter
+ #:+key-kp-equal
+ #:+key-kp-multiply
+ #:+key-kp-subtract
+ #:+key-lalt
+ #:+key-last
+ #:+key-lctrl
+ #:+key-left
+ #:+key-lshift
+ #:+key-pagedown
+ #:+key-pageup
+ #:+key-ralt
+ #:+key-rctrl
+ #:+key-repeat
+ #:+key-right
+ #:+key-rshift
+ #:+key-space
+ #:+key-special
+ #:+key-tab
+ #:+key-unknown
+ #:+key-up
+ #:+mouse-button-1
+ #:+mouse-button-2
+ #:+mouse-button-3
+ #:+mouse-button-4
+ #:+mouse-button-5
+ #:+mouse-button-6
+ #:+mouse-button-7
+ #:+mouse-button-8
+ #:+mouse-button-last
+ #:+mouse-button-left
+ #:+mouse-button-middle
+ #:+mouse-button-right
+ #:+mouse-cursor
+ #:+no-rescale-bit
+ #:+nowait
+ #:+opened
+ #:+origin-ul-bit
+ #:+present
+ #:+press
+ #:+red-bits
+ #:+refresh-rate
+ #:+release
+ #:+stencil-bits
+ #:+stereo
+ #:+sticky-keys
+ #:+sticky-mouse-buttons
+ #:+system-keys
+ #:+wait
+ #:+window
+ #:+window-no-resize
+ #:broadcast-cond
#:close-window
#:create-cond
#:create-mutex
#:create-thread
#:defcfun
+doc
#:defcfun
+out
+doc
#:destroy-cond
#:destroy-mutex
#:destroy-thread
#:disable
#:enable
#:extension-supported
#:free-image
#:get-desktop-mode
#:get-gl-version
#:get-joystick-buttons
#:get-joystick-param
#:get-joystick-pos
#:get-key
#:get-mouse-button
#:get-mouse-pos
#:get-mouse-wheel
#:get-number-of-processors
#:get-proc-address
#:get-thread-id
#:get-time
#:get-version
#:get-video-modes
#:get-window-param
#:get-window-size
#:iconify-window
#:init
#:load-memory-texture-2d
#:load-texture-2d
#:load-texture-image-2d
#:lock-mutex
#:open-window
#:open-window-hint
#:poll-events
#:read-image
#:read-memory-image
#:restore-window
#:set-char-callback
#:set-key-callback
#:set-mouse-button-callback
#:set-mouse-pos
#:set-mouse-pos-callback
#:set-mouse-wheel
#:set-mouse-wheel-callback
#:set-time
#:set-window-close-callback
#:set-window-pos
#:set-window-refresh-callback
#:set-window-size
#:set-window-size-callback
#:set-window-title
#:signal-cond
#:sleep
#:swap-buffers
#:swap-interval
#:terminate
#:unlock-mutex
#:wait-cond
#:wait-events
#:wait-thread
13 #| exports generated by this
, after the package is loaded
:
14 (format t
"~{#:~a~^ ~}"
15 (sort (mapcar #'(lambda (s) (string-downcase (format nil
"~a" s
)))
16 (remove-if-not #'(lambda (s)
17 (and (eql (symbol-package s
) (find-package '#:glfw
))
18 (or (constantp s
) (fboundp s
))))
19 (loop for s being each symbol in
'#:glfw collecting s
)))
25 (defmacro defcfun
+doc
((c-name lisp-name
) return-type
(&body args
) docstring
)
27 (defcfun (,c-name
,lisp-name
) ,return-type
,@args
)
28 (setf (documentation #',lisp-name
'function
) ,docstring
)))
30 (defmacro defcfun
+out
+doc
((c-name lisp-name
) return-type
(&body args
) docstring
)
31 (let ((internal-name (intern (format nil
"%~a" lisp-name
)))
32 (in-arg-names (mapcar #'second
(remove-if-not #'(lambda (arg)
35 (out-args (mapcar #'cdr
(remove-if-not #'(lambda (arg)
39 (defcfun (,c-name
,internal-name
) ,return-type
40 ,@(mapcar #'(lambda (arg)
41 (if (eql (car arg
) :out
)
42 (list (second arg
) :pointer
)
45 (defun ,lisp-name
,in-arg-names
47 (with-foreign-objects ,out-args
48 (,internal-name
,@(mapcar #'second args
))
49 (list ,@(mapcar #'(lambda (arg)
50 `(mem-ref ,(first arg
) ',(second arg
)))
54 (load-foreign-library '(:or
56 (:default
"libglfw")))
58 ;; Key and button state/action definitions
59 (defconstant +release
+ 0)
60 (defconstant +press
+ 1)
62 ;; Keyboard key definitions: 8-bit ISO-8859-1 (Latin 1) encoding is used
63 ;; for printable keys (such as A-Z, 0-9 etc), and values above 256
64 ;; represent special (non-printable) keys (e.g. F1, Page Up etc).
65 (defconstant +key-unknown
+ -
1)
66 (defconstant +key-space
+ 32)
67 (defconstant +key-special
+ 256)
68 (defconstant +key-esc
+ (+ +key-special
+ 1))
69 (defconstant +key-f1
+ (+ +key-special
+ 2))
70 (defconstant +key-f2
+ (+ +key-special
+ 3))
71 (defconstant +key-f3
+ (+ +key-special
+ 4))
72 (defconstant +key-f4
+ (+ +key-special
+ 5))
73 (defconstant +key-f5
+ (+ +key-special
+ 6))
74 (defconstant +key-f6
+ (+ +key-special
+ 7))
75 (defconstant +key-f7
+ (+ +key-special
+ 8))
76 (defconstant +key-f8
+ (+ +key-special
+ 9))
77 (defconstant +key-f9
+ (+ +key-special
+ 10))
78 (defconstant +key-f10
+ (+ +key-special
+ 11))
79 (defconstant +key-f11
+ (+ +key-special
+ 12))
80 (defconstant +key-f12
+ (+ +key-special
+ 13))
81 (defconstant +key-f13
+ (+ +key-special
+ 14))
82 (defconstant +key-f14
+ (+ +key-special
+ 15))
83 (defconstant +key-f15
+ (+ +key-special
+ 16))
84 (defconstant +key-f16
+ (+ +key-special
+ 17))
85 (defconstant +key-f17
+ (+ +key-special
+ 18))
86 (defconstant +key-f18
+ (+ +key-special
+ 19))
87 (defconstant +key-f19
+ (+ +key-special
+ 20))
88 (defconstant +key-f20
+ (+ +key-special
+ 21))
89 (defconstant +key-f21
+ (+ +key-special
+ 22))
90 (defconstant +key-f22
+ (+ +key-special
+ 23))
91 (defconstant +key-f23
+ (+ +key-special
+ 24))
92 (defconstant +key-f24
+ (+ +key-special
+ 25))
93 (defconstant +key-f25
+ (+ +key-special
+ 26))
94 (defconstant +key-up
+ (+ +key-special
+ 27))
95 (defconstant +key-down
+ (+ +key-special
+ 28))
96 (defconstant +key-left
+ (+ +key-special
+ 29))
97 (defconstant +key-right
+ (+ +key-special
+ 30))
98 (defconstant +key-lshift
+ (+ +key-special
+ 31))
99 (defconstant +key-rshift
+ (+ +key-special
+ 32))
100 (defconstant +key-lctrl
+ (+ +key-special
+ 33))
101 (defconstant +key-rctrl
+ (+ +key-special
+ 34))
102 (defconstant +key-lalt
+ (+ +key-special
+ 35))
103 (defconstant +key-ralt
+ (+ +key-special
+ 36))
104 (defconstant +key-tab
+ (+ +key-special
+ 37))
105 (defconstant +key-enter
+ (+ +key-special
+ 38))
106 (defconstant +key-backspace
+ (+ +key-special
+ 39))
107 (defconstant +key-insert
+ (+ +key-special
+ 40))
108 (defconstant +key-del
+ (+ +key-special
+ 41))
109 (defconstant +key-pageup
+ (+ +key-special
+ 42))
110 (defconstant +key-pagedown
+ (+ +key-special
+ 43))
111 (defconstant +key-home
+ (+ +key-special
+ 44))
112 (defconstant +key-end
+ (+ +key-special
+ 45))
113 (defconstant +key-kp-0
+ (+ +key-special
+ 46))
114 (defconstant +key-kp-1
+ (+ +key-special
+ 47))
115 (defconstant +key-kp-2
+ (+ +key-special
+ 48))
116 (defconstant +key-kp-3
+ (+ +key-special
+ 49))
117 (defconstant +key-kp-4
+ (+ +key-special
+ 50))
118 (defconstant +key-kp-5
+ (+ +key-special
+ 51))
119 (defconstant +key-kp-6
+ (+ +key-special
+ 52))
120 (defconstant +key-kp-7
+ (+ +key-special
+ 53))
121 (defconstant +key-kp-8
+ (+ +key-special
+ 54))
122 (defconstant +key-kp-9
+ (+ +key-special
+ 55))
123 (defconstant +key-kp-divide
+ (+ +key-special
+ 56))
124 (defconstant +key-kp-multiply
+ (+ +key-special
+ 57))
125 (defconstant +key-kp-subtract
+ (+ +key-special
+ 58))
126 (defconstant +key-kp-add
+ (+ +key-special
+ 59))
127 (defconstant +key-kp-decimal
+ (+ +key-special
+ 60))
128 (defconstant +key-kp-equal
+ (+ +key-special
+ 61))
129 (defconstant +key-kp-enter
+ (+ +key-special
+ 62))
130 (defconstant +key-last
+ +key-kp-enter
+)
132 ;; Mouse button definitions
133 (defconstant +mouse-button-1
+ 0)
134 (defconstant +mouse-button-2
+ 1)
135 (defconstant +mouse-button-3
+ 2)
136 (defconstant +mouse-button-4
+ 3)
137 (defconstant +mouse-button-5
+ 4)
138 (defconstant +mouse-button-6
+ 5)
139 (defconstant +mouse-button-7
+ 6)
140 (defconstant +mouse-button-8
+ 7)
141 (defconstant +mouse-button-last
+ +mouse-button-8
+)
143 ;; Mouse button aliases
144 (defconstant +mouse-button-left
+ +mouse-button-1
+)
145 (defconstant +mouse-button-right
+ +mouse-button-2
+)
146 (defconstant +mouse-button-middle
+ +mouse-button-3
+)
148 ;; Joystick identifiers
149 (defconstant +joystick-1
+ 0)
150 (defconstant +joystick-2
+ 1)
151 (defconstant +joystick-3
+ 2)
152 (defconstant +joystick-4
+ 3)
153 (defconstant +joystick-5
+ 4)
154 (defconstant +joystick-6
+ 5)
155 (defconstant +joystick-7
+ 6)
156 (defconstant +joystick-8
+ 7)
157 (defconstant +joystick-9
+ 8)
158 (defconstant +joystick-10
+ 9)
159 (defconstant +joystick-11
+ 10)
160 (defconstant +joystick-12
+ 11)
161 (defconstant +joystick-13
+ 12)
162 (defconstant +joystick-14
+ 13)
163 (defconstant +joystick-15
+ 14)
164 (defconstant +joystick-16
+ 15)
165 (defconstant +joystick-last
+ +joystick-16
+)
168 ;;========================================================================
170 ;;========================================================================
172 ;; glfwOpenWindow modes
173 (defconstant +window
+ #x00010001
)
174 (defconstant +fullscreen
+ #x00010002
)
176 ;; glfwGetWindowParam tokens
177 (defconstant +opened
+ #x00020001
)
178 (defconstant +active
+ #x00020002
)
179 (defconstant +iconified
+ #x00020003
)
180 (defconstant +accelerated
+ #x00020004
)
181 (defconstant +red-bits
+ #x00020005
)
182 (defconstant +green-bits
+ #x00020006
)
183 (defconstant +blue-bits
+ #x00020007
)
184 (defconstant +alpha-bits
+ #x00020008
)
185 (defconstant +depth-bits
+ #x00020009
)
186 (defconstant +stencil-bits
+ #x0002000a
)
188 ;; The following constants are used for both glfwGetWindowParam
189 ;; and glfwOpenWindowHint
190 (defconstant +refresh-rate
+ #x0002000b
)
191 (defconstant +accum-red-bits
+ #x0002000c
)
192 (defconstant +accum-green-bits
+ #x0002000d
)
193 (defconstant +accum-blue-bits
+ #x0002000e
)
194 (defconstant +accum-alpha-bits
+ #x0002000f
)
195 (defconstant +aux-buffers
+ #x00020010
)
196 (defconstant +stereo
+ #x00020011
)
197 (defconstant +window-no-resize
+ #x00020012
)
198 (defconstant +fsaa-samples
+ #x00020013
)
200 ;; glfwEnable/glfwDisable tokens
201 (defconstant +mouse-cursor
+ #x00030001
)
202 (defconstant +sticky-keys
+ #x00030002
)
203 (defconstant +sticky-mouse-buttons
+ #x00030003
)
204 (defconstant +system-keys
+ #x00030004
)
205 (defconstant +key-repeat
+ #x00030005
)
206 (defconstant +auto-poll-events
+ #x00030006
)
208 ;; glfwWaitThread wait modes
209 (defconstant +wait
+ #x00040001
)
210 (defconstant +nowait
+ #x00040002
)
212 ;; glfwGetJoystickParam tokens
213 (defconstant +present
+ #x00050001
)
214 (defconstant +axes
+ #x00050002
)
215 (defconstant +buttons
+ #x00050003
)
217 ;; glfwReadImage/glfwLoadTexture2D flags
218 (defconstant +no-rescale-bit
+ #x00000001
) ; Only for glfwReadImage
219 (defconstant +origin-ul-bit
+ #x00000002
)
220 (defconstant +build-mipmaps-bit
+ #x00000004
) ; Only for glfwLoadTexture2D
221 (defconstant +alpha-map-bit
+ #x00000008
)
223 ;; Time spans longer than this (seconds) are considered to be infinity
224 (defconstant +infinity
+ 100000.0)
226 ;; (declaim (ftype (function () (member gl:+true+ gl:+false+)) init))
227 (defcfun+doc
("glfwInit" init
) :int
()
229 If the function succeeds, GL_TRUE is returned.
230 If the function fails, GL_FALSE is returned.
232 The glfwInit function initializes GLFW. No other GLFW functions may be used before this function
236 This function may take several seconds to complete on some systems, while on other systems it may
237 take only a fraction of a second to complete.")
239 (defcfun+doc
("glfwTerminate" terminate
) :void
()
240 "The function terminates GLFW. Among other things it closes the window, if it is opened, and kills any
241 running threads. This function must be called before a program exits.")
243 (defcfun+out
+doc
("glfwGetVersion" get-version
) :void
((:out major
:int
)
247 The function returns the major and minor version numbers and the revision for the currently linked
248 GLFW library as a list (major minor rev).")
251 ;; (declaim (ftype (function () (member gl:+true+ gl:+false+)) open-window))
252 (defcfun+doc
("glfwOpenWindow" open-window
) :int
253 ((width :int
) (height :int
)
254 (redbits :int
) (greenbits :int
) (bluebits :int
) (alphabits :int
)
255 (depthbits :int
) (stencilbits :int
) (mode :int
))
257 The width of the window. If width is zero, it will be calculated as width = 4 height, if height is
259 not zero. If both width and height are zero, then width will be set to 640.
262 The height of the window. If height is zero, it will be calculated as height = 4 width, if width is
263 not zero. If both width and height are zero, then height will be set to 480.
264 redbits, greenbits, bluebits
265 The number of bits to use for each color component of the color buffer (0 means default color
266 depth). For instance, setting redbits=5, greenbits=6, and bluebits=5 will generate a 16-bit color
269 The number of bits to use for the alpha buffer (0 means no alpha buffer).
271 The number of bits to use for the depth buffer (0 means no depth buffer).
273 The number of bits to use for the stencil buffer (0 means no stencil buffer).
275 Selects which type of OpenGL™ window to use. mode can be either GLFW_WINDOW, which
276 will generate a normal desktop window, or GLFW_FULLSCREEN, which will generate a
277 window which covers the entire screen. When GLFW_FULLSCREEN is selected, the video
278 mode will be changed to the resolution that closest matches the width and height parameters.
281 If the function succeeds, GL_TRUE is returned.
282 If the function fails, GL_FALSE is returned.
285 The function opens a window that best matches the parameters given to the function. How well the
286 resulting window matches the desired window depends mostly on the available hardware and
287 OpenGL™ drivers. In general, selecting a fullscreen mode has better chances of generating a close
288 match than does a normal desktop window, since GLFW can freely select from all the available video
289 modes. A desktop window is normally restricted to the video mode of the desktop.
292 For additional control of window properties, see glfwOpenWindowHint.
293 In fullscreen mode the mouse cursor is hidden by default, and any system screensavers are prohibited
294 from starting. In windowed mode the mouse cursor is visible, and screensavers are allowed to start. To
295 change the visibility of the mouse cursor, use glfwEnable or glfwDisable with the argument
297 In order to determine the actual properties of an opened window, use glfwGetWindowParam and
298 glfwGetWindowSize (or glfwSetWindowSizeCallback).
301 (defcfun+doc
("glfwOpenWindowHint" open-window-hint
) :void
((target :int
) (hint :int
))
303 Can be any of the constants in the table 3.1.
305 An integer giving the value of the corresponding target (see table 3.1).
308 The function sets additional properties for a window that is to be opened. For a hint to be registered, the
309 function must be called before calling glfwOpenWindow. When the glfwOpenWindow function is
310 called, any hints that were registered with the glfwOpenWindowHint function are used for setting the
311 corresponding window properties, and then all hints are reset to their default values.
314 In order to determine the actual properties of an opened window, use glfwGetWindowParam (after the
315 window has been opened).
316 GLFW_STEREO is a hard constraint. If stereo rendering is requested, but no stereo rendering capable
317 pixel formats / visuals are available, glfwOpenWindow will fail.
318 The GLFW_REFRESH-RATE property should be used with caution. Most systems have default values
319 for monitor refresh rates that are optimal for the specific system. Specifying the refresh rate can
320 override these settings, which can result in suboptimal operation. The monitor may be unable to display
321 the resulting video signal, or in the worst case it may even be damaged!
324 (defcfun+doc
("glfwCloseWindow" close-window
) :void
()
325 "The function closes an opened window and destroys the associated OpenGL™ context.")
327 (defcfun+doc
("glfwSetWindowCloseCallback" set-window-close-callback
) :void
((cbfun :pointer
))
330 Pointer to a callback function that will be called when a user requests that the window should be
331 closed, typically by clicking the window close icon (e.g. the cross in the upper right corner of a
332 window under Microsoft Windows). The function should have the following C language
334 int GLFWCALL functionname( void );
335 Where functionname is the name of the callback function. The return value of the callback
336 function indicates wether or not the window close action should continue. If the function returns
337 GL_TRUE, the window will be closed. If the function returns GL_FALSE, the window will not
339 If cbfun is NULL, any previously selected callback function will be deselected.
342 The function selects which function to be called upon a window close event.
343 A window has to be opened for this function to have any effect.
346 Window close events are recorded continuously, but only reported when glfwPollEvents,
347 glfwWaitEvents or glfwSwapBuffers is called.
348 The OpenGL™ context is still valid when this function is called.
349 Note that the window close callback function is not called when glfwCloseWindow is called, but only
350 when the close request comes from the window manager.
351 Do not call glfwCloseWindow from a window close callback function. Close the window by returning
352 GL_TRUE from the function.
355 (defcfun+doc
("glfwSetWindowTitle" set-window-title
) :void
((title :string
))
358 Pointer to a null terminated ISO 8859-1 (8-bit Latin 1) string that holds the title of the window.
361 The function changes the title of the opened window.
364 The title property of a window is often used in situations other than for the window title, such as the title
365 of an application icon when it is in iconified state.")
367 (defcfun+doc
("glfwSetWindowSize" set-window-size
) :void
((width :int
) (height :int
))
372 Height of the window.
376 The function changes the size of an opened window. The width and height parameters denote the size of
377 the client area of the window (i.e. excluding any window borders and decorations).
378 If the window is in fullscreen mode, the video mode will be changed to a resolution that closest matches
379 the width and height parameters (the number of color bits will not be changed).
381 The OpenGL™ context is guaranteed to be preserved after calling glfwSetWindowSize, even if the
382 video mode is changed.
385 (defcfun+doc
("glfwSetWindowPos" set-window-pos
) :void
((x :int
) (y :int
))
388 Horizontal position of the window, relative to the upper left corner of the desktop.
390 Vertical position of the window, relative to the upper left corner of the desktop.
394 The function changes the position of an opened window. It does not have any effect on a fullscreen
398 (defcfun ("glfwGetWindowSize" %get-window-size
) :void
(width :pointer
) (height :pointer
))
399 (defun get-window-size ()
400 "The function is used for determining the size of an opened window. The returned values are dimensions
401 of the client area of the window (i.e. excluding any window borders and decorations).
403 (cffi:with-foreign-objects
((width :int
)
405 (%get-window-size width height
)
406 (list (mem-ref width
:int
)
407 (mem-ref height
:int
))))
409 (defcfun+doc
("glfwSetWindowSizeCallback" set-window-size-callback
) :void
((cbfun :pointer
))
412 Pointer to a callback function that will be called every time the window size changes. The
413 function should have the following C language prototype:
414 void GLFWCALL functionname( int width, int height );
415 Where functionname is the name of the callback function, and width and height are the
416 dimensions of the window client area.
417 If cbfun is NULL, any previously selected callback function will be deselected.
421 The function selects which function to be called upon a window size change event.
422 A window has to be opened for this function to have any effect.
424 Window size changes are recorded continuously, but only reported when glfwPollEvents,
425 glfwWaitEvents or glfwSwapBuffers is called. ")
427 (defcfun+doc
("glfwIconifyWindow" iconify-window
) :void
()
428 "Iconify a window. If the window is in fullscreen mode, then the desktop video mode will be restored.")
430 (defcfun+doc
("glfwRestoreWindow" restore-window
) :void
()
431 "Restore an iconified window. If the window that is restored is in fullscreen mode, then the fullscreen
432 video mode will be restored.")
434 (defcfun+doc
("glfwGetWindowParam" get-window-param
) :int
((param :int
))
437 A token selecting which parameter the function should return (see table 3.2).
440 The function returns different parameters depending on the value of param. Table 3.2 lists valid param
441 values, and their corresponding return values.
444 The function is used for acquiring various properties of an opened window.
447 GLFW_ACCELERATED is only supported under Windows. Other systems will always return
448 GL_TRUE. Under Windows, GLFW_ACCELERATED means that the OpenGL™ renderer is a 3rd
449 party renderer, rather than the fallback Microsoft software OpenGL™ renderer. In other words, it is
450 not a real guarantee that the OpenGL™ renderer is actually hardware accelerated.
453 (defcfun+doc
("glfwSwapBuffers" swap-buffers
) :void
()
454 "The function swaps the back and front color buffers of the window. If GLFW_AUTO-POLL-EVENTS
455 is enabled (which is the default), glfwPollEvents is called before swapping the front and back buffers.")
458 (defcfun+doc
("glfwSwapInterval" swap-interval
) :void
((interval :int
))
461 Minimum number of monitor vertical retraces between each buffer swap performed by
462 glfwSwapBuffers. If interval is zero, buffer swaps will not be synchronized to the vertical
463 refresh of the monitor (also known as ’VSync off’).
466 The function selects the minimum number of monitor vertical retraces that should occur between two
467 buffer swaps. If the selected swap interval is one, the rate of buffer swaps will never be higher than the
468 vertical refresh rate of the monitor. If the selected swap interval is zero, the rate of buffer swaps is only
469 limited by the speed of the software and the hardware.
472 This function will only have an effect on hardware and drivers that support user selection of the swap
476 (defcfun+doc
("glfwSetWindowRefreshCallback" set-window-refresh-callback
) :void
((cbfun :pointer
))
479 Pointer to a callback function that will be called when the window client area needs to be
480 refreshed. The function should have the following C language prototype:
481 void GLFWCALL functionname( void );
482 Where functionname is the name of the callback function.
483 If cbfun is NULL, any previously selected callback function will be deselected.
486 The function selects which function to be called upon a window refresh event, which occurs when any
487 part of the window client area has been damaged, and needs to be repainted (for instance, if a part of the
488 window that was previously occluded by another window has become visible).
489 A window has to be opened for this function to have any effect.
492 Window refresh events are recorded continuously, but only reported when glfwPollEvents,
493 glfwWaitEvents or glfwSwapBuffers is called.
503 (defcfun ("glfwGetVideoModes" %get-video-modes
) :int
(list :pointer
) (maxcount :int
))
505 (defun get-video-modes (maxcount)
508 Maximum number of video modes that list vector can hold.
511 The function returns the number of detected video modes (this number will never exceed maxcount).
512 The list vector is filled out with the video modes that are supported by the system.
515 The function returns a list of supported video modes. Each video mode is represented by a
517 (width height redbits greenbits bluebits)
520 The returned list is sorted, first by color depth (RedBits + GreenBits + BlueBits), and then by
521 resolution (Width × Height), with the lowest resolution, fewest bits per pixel mode first. "
522 (with-foreign-object (list 'vidmode maxcount
)
523 (let ((count (%get-video-modes list maxcount
)))
524 (loop for i below count
527 (list (foreign-slot-value mode
'vidmode
'width
)
528 (foreign-slot-value mode
'vidmode
'height
)
529 (foreign-slot-value mode
'vidmode
'redbits
)
530 (foreign-slot-value mode
'vidmode
'greenbits
)
531 (foreign-slot-value mode
'vidmode
'bluebits
))))))
533 (defcfun ("glfwGetDesktopMode" %get-desktop-mode
) :void
(mode :pointer
))
534 (defun get-desktop-mode ()
537 Pointer to a GLFWvidmode structure, which will be filled out by the function.
539 The GLFWvidmode structure pointed to by mode is filled out with the desktop video mode.
541 The function returns the desktop video mode in a GLFWvidmode structure. See glfwGetVideoModes
542 for a definition of the GLFWvidmode structure.
544 The color depth of the desktop display is always reported as the number of bits for each individual color
545 component (red, green and blue), even if the desktop is not using an RGB or RGBA color format. For
546 instance, an indexed 256 color display may report RedBits = 3, GreenBits = 3 and BlueBits = 2, which
547 adds up to 8 bits in total.
548 The desktop video mode is the video mode used by the desktop, not the current video mode (which may
549 differ from the desktop video mode if the GLFW window is a fullscreen window).
551 (with-foreign-object (mode 'vidmode
)
552 (list (foreign-slot-value mode
'vidmode
'width
)
553 (foreign-slot-value mode
'vidmode
'height
)
554 (foreign-slot-value mode
'vidmode
'redbits
)
555 (foreign-slot-value mode
'vidmode
'greenbits
)
556 (foreign-slot-value mode
'vidmode
'bluebits
))))
558 (defcfun+doc
("glfwPollEvents" poll-events
) :void
()
560 The function is used for polling for events, such as user input and window resize events. Upon calling
561 this function, all window states, keyboard states and mouse states are updated. If any related callback
562 functions are registered, these are called during the call to glfwPollEvents.
565 glfwPollEvents is called implicitly from glfwSwapBuffers if GLFW_AUTO_POLL_EVENTS is
566 enabled (default). Thus, if glfwSwapBuffers is called frequently, which is normally the case, there is
567 no need to call glfwPollEvents.
570 (defcfun+doc
("glfwWaitEvents" wait-events
) :void
()
572 The function is used for waiting for events, such as user input and window resize events. Upon calling
573 this function, the calling thread will be put to sleep until any event appears in the event queue. When
574 events are ready, the events will be processed just as they are processed by glfwPollEvents.
575 If there are any events in the queue when the function is called, the function will behave exactly like
576 glfwPollEvents (i.e. process all messages and then return, without blocking the calling thread).
579 It is guaranteed that glfwWaitEvents will wake up on any event that can be processed by
580 glfwPollEvents. However, glfwWaitEvents may wake up on events that are not processed or reported
581 by glfwPollEvents too, and the function may behave differently on different systems. Do no make any
582 assumptions about when or why glfwWaitEvents will return.
585 (defcfun+doc
("glfwGetKey" get-key
) :int
((key :int
))
588 A keyboard key identifier, which can be either an uppercase printable ISO 8859-1 (Latin 1)
589 character (e.g. 'A', '3' or '.'), or a special key identifier. Table 3.3 lists valid special key
592 The function returns GLFW_PRESS if the key is held down, or GLFW_RELEASE if the key is not
596 The function queries the current state of a specific keyboard key. The physical location of each key
597 depends on the system keyboard layout setting.
600 The constant GLFW_KEY_SPACE is equal to 32, which is the ISO 8859-1 code for space.
601 Not all key codes are supported on all systems. Also, while some keys are available on some keyboard
602 layouts, they may not be available on other keyboard layouts.
603 For systems that do not distinguish between left and right versions of modifier keys (shift, alt and
604 control), the left version is used (e.g. GLFW_KEY_LSHIFT).
605 A window must be opened for the function to have any effect, and glfwPollEvents, glfwWaitEvents or
606 glfwSwapBuffers must be called before any keyboard events are recorded and reported by
610 (defcfun+doc
("glfwGetMouseButton" get-mouse-button
) :int
((button :int
))
613 A mouse button identifier, which can be one of the mouse button identifiers listed in table 3.4.
615 The function returns GLFW_PRESS if the mouse button is held down, or GLFW_RELEASE if the
616 mouse button is not held down.
618 The function queries the current state of a specific mouse button.
620 A window must be opened for the function to have any effect, and glfwPollEvents, glfwWaitEvents or
621 glfwSwapBuffers must be called before any mouse button events are recorded and reported by
623 GLFW_MOUSE_BUTTON_LEFT is equal to GLFW_MOUSE_BUTTON_1.
624 GLFW_MOUSE_BUTTON_RIGHT is equal to GLFW_MOUSE_BUTTON_2.
625 GLFW_MOUSE_BUTTON_MIDDLE is equal to GLFW_MOUSE_BUTTON_3.
629 (defcfun+out
+doc
("glfwGetMousePos" get-mouse-pos
) :void
((:out xpos
:int
) (:out ypos
:int
))
631 The function returns the current mouse position in xpos and ypos.
634 The function returns the current mouse position. If the cursor is not hidden, the mouse position is the
635 cursor position, relative to the upper left corner of the window and limited to the client area of the
636 window. If the cursor is hidden, the mouse position is a virtual absolute position, not limited to any
637 boundaries except to those implied by the maximum number that can be represented by a signed integer
638 (normally -2147483648 to +2147483647).
641 A window must be opened for the function to have any effect, and glfwPollEvents, glfwWaitEvents or
642 glfwSwapBuffers must be called before any mouse movements are recorded and reported by
647 (defcfun+doc
("glfwSetMousePos" set-mouse-pos
) :void
((xpos :int
) (ypos :int
))
650 Horizontal position of the mouse.
652 Vertical position of the mouse.
655 The function changes the position of the mouse. If the cursor is visible (not disabled), the cursor will be
656 moved to the specified position, relative to the upper left corner of the window client area. If the cursor
657 is hidden (disabled), only the mouse position that is reported by GLFW is changed.
660 (defcfun+doc
("glfwGetMouseWheel" get-mouse-wheel
) :int
()
662 The function returns the current mouse wheel position.
664 The function returns the current mouse wheel position. The mouse wheel can be thought of as a third
665 mouse axis, which is available as a separate wheel or up/down stick on some mice.
667 A window must be opened for the function to have any effect, and glfwPollEvents, glfwWaitEvents or
668 glfwSwapBuffers must be called before any mouse wheel movements are recorded and reported by
672 (defcfun+doc
("glfwSetMouseWheel" set-mouse-wheel
) :void
((pos :int
))
675 Position of the mouse wheel.
677 The function changes the position of the mouse wheel.
681 (defcfun+doc
("glfwSetKeyCallback" set-key-callback
) :void
((cbfun :pointer
))
684 Pointer to a callback function that will be called every time a key is pressed or released. The
685 function should have the following C language prototype:
686 void GLFWCALL functionname( int key, int action );
687 Where functionname is the name of the callback function, key is a key identifier, which is an
688 uppercase printable ISO 8859-1 character or a special key identifier (see table 3.3), and action is
689 either GLFW_PRESS or GLFW_RELEASE.
690 If cbfun is NULL, any previously selected callback function will be deselected.
694 The function selects which function to be called upon a keyboard key event. The callback function is
695 called every time the state of a single key is changed (from released to pressed or vice versa). The
696 reported keys are unaffected by any modifiers (such as shift or alt).
697 A window has to be opened for this function to have any effect.
699 Keyboard events are recorded continuously, but only reported when glfwPollEvents, glfwWaitEvents
700 or glfwSwapBuffers is called.
702 (defcfun+doc
("glfwSetCharCallback" set-char-callback
) :void
((cbfun :pointer
))
705 Pointer to a callback function that will be called every time a printable character is generated by
706 the keyboard. The function should have the following C language prototype:
707 void GLFWCALL functionname( int character, int action );
708 Where functionname is the name of the callback function, character is a Unicode (ISO 10646)
709 character, and action is either GLFW_PRESS or GLFW_RELEASE.
710 If cbfun is NULL, any previously selected callback function will be deselected.
714 The function selects which function to be called upon a keyboard character event. The callback function
715 is called every time a key that results in a printable Unicode character is pressed or released. Characters
716 are affected by modifiers (such as shift or alt).
717 A window has to be opened for this function to have any effect.
719 Character events are recorded continuously, but only reported when glfwPollEvents, glfwWaitEvents
720 or glfwSwapBuffers is called.
721 Control characters, such as tab and carriage return, are not reported to the character callback function,
722 since they are not part of the Unicode character set. Use the key callback function for such events (see
724 The Unicode character set supports character codes above 255, so never cast a Unicode character to an
725 eight bit data type (e.g. the C language ’char’ type) without first checking that the character code is less
726 than 256. Also note that Unicode character codes 0 to 255 are equal to ISO 8859-1 (Latin 1).
728 (defcfun+doc
("glfwSetMouseButtonCallback" set-mouse-button-callback
) :void
((cbfun :pointer
))
731 Pointer to a callback function that will be called every time a mouse button is pressed or released.
732 The function should have the following C language prototype:
733 void GLFWCALL functionname( int button, int action );
734 Where functionname is the name of the callback function, button is a mouse button identifier (see
735 table 3.4 on page 56), and action is either GLFW_PRESS or GLFW_RELEASE.
736 If cbfun is NULL, any previously selected callback function will be deselected.
740 The function selects which function to be called upon a mouse button event.
741 A window has to be opened for this function to have any effect.
743 Mouse button events are recorded continuously, but only reported when glfwPollEvents,
744 glfwWaitEvents or glfwSwapBuffers is called.
745 GLFW_MOUSE_BUTTON_LEFT is equal to GLFW_MOUSE_BUTTON_1.
746 GLFW_MOUSE_BUTTON_RIGHT is equal to GLFW_MOUSE_BUTTON_2.
747 GLFW_MOUSE_BUTTON_MIDDLE is equal to GLFW_MOUSE_BUTTON_3.
749 (defcfun+doc
("glfwSetMousePosCallback" set-mouse-pos-callback
) :void
((cbfun :pointer
))
752 Pointer to a callback function that will be called every time the mouse is moved. The function
753 should have the following C language prototype:
754 void GLFWCALL functionname( int x, int y );
755 Where functionname is the name of the callback function, and x and y are the mouse coordinates
756 (see glfwGetMousePos for more information on mouse coordinates).
757 If cbfun is NULL, any previously selected callback function will be deselected.
761 The function selects which function to be called upon a mouse motion event.
762 A window has to be opened for this function to have any effect.
764 Mouse motion events are recorded continuously, but only reported when glfwPollEvents,
765 glfwWaitEvents or glfwSwapBuffers is called.
767 (defcfun+doc
("glfwSetMouseWheelCallback" set-mouse-wheel-callback
) :void
((cbfun :pointer
))
770 Pointer to a callback function that will be called every time the mouse wheel is moved. The
771 function should have the following C language prototype:
772 void GLFWCALL functionname( int pos );
773 Where functionname is the name of the callback function, and pos is the mouse wheel position.
774 If cbfun is NULL, any previously selected callback function will be deselected.
778 The function selects which function to be called upon a mouse wheel event.
779 A window has to be opened for this function to have any effect.
781 Mouse wheel events are recorded continuously, but only reported when glfwPollEvents,
782 glfwWaitEvents or glfwSwapBuffers is called.
785 (defcfun+doc
("glfwGetJoystickParam" get-joystick-param
) :int
((joy :int
) (param :int
))
788 A joystick identifier, which should be GLFW_JOYSTICK_n, where n is in the range 1 to 16.
790 A token selecting which parameter the function should return (see table 3.5).
792 The function returns different parameters depending on the value of param. Table 3.5 lists valid param
793 values, and their corresponding return values.
795 The function is used for acquiring various properties of a joystick.
797 The joystick information is updated every time the function is called.
798 No window has to be opened for joystick information to be valid.
801 (defcfun ("glfwGetJoystickPos" %get-joystick-pos
) :int
(joy :int
) (pos :pointer
) (numaxes :int
))
803 (defun get-joystick-pos (joy numaxes
)
806 A joystick identifier, which should be GLFW_JOYSTICK_n, where n is in the range 1 to 16.
808 Specifies how many axes should be returned.
810 An list that will hold the positional values for all requested axes.
811 If the joystick is not supported or connected, the function will
815 The function queries the current position of one or more axes of a joystick. The positional values are
816 returned in an array, where the first element represents the first axis of the joystick (normally the X
817 axis). Each position is in the range -1.0 to 1.0. Where applicable, the positive direction of an axis is
818 right, forward or up, and the negative direction is left, back or down.
819 If numaxes exceeds the number of axes supported by the joystick, or if the joystick is not available, the
820 unused elements in the pos array will be set to 0.0 (zero).
823 The joystick state is updated every time the function is called, so there is no need to call glfwPollEvents
824 or glfwWaitEvents for joystick state to be updated.
825 Use glfwGetJoystickParam to retrieve joystick capabilities, such as joystick availability and number of
827 No window has to be opened for joystick input to be valid.
829 (with-foreign-object (pos :float numaxes
)
830 (let ((numaxes (%get-joystick-pos joy pos numaxes
)))
831 (loop for i below numaxes collecting
(mem-aref pos
:float i
)))))
834 (defcfun ("glfwGetJoystickButtons" %get-joystick-buttons
) :int
(joy :int
) (buttons :pointer
) (numbuttons :int
))
835 (defun get-joystick-buttons (joy numbuttons
)
838 A joystick identifier, which should be GLFW_JOYSTICK_n, where n is in the range 1 to 16.
840 Specifies how many buttons should be returned.
842 A list that will hold the button states for all requested buttons.
843 The function returns the number of actually returned buttons. This is the minimum of numbuttons and
844 the number of buttons supported by the joystick. If the joystick is not supported or connected, the
845 function will return 0 (zero).
848 The function queries the current state of one or more buttons of a joystick. The button states are
849 returned in an array, where the first element represents the first button of the joystick. Each state can be
850 either GLFW_PRESS or GLFW_RELEASE.
851 If numbuttons exceeds the number of buttons supported by the joystick, or if the joystick is not
852 available, the unused elements in the buttons array will be set to GLFW_RELEASE.
855 The joystick state is updated every time the function is called, so there is no need to call glfwPollEvents
856 or glfwWaitEvents for joystick state to be updated.
857 Use glfwGetJoystickParam to retrieve joystick capabilities, such as joystick availability and number of
859 No window has to be opened for joystick input to be valid.
861 (with-foreign-object (buttons :unsigned-char numbuttons
)
862 (let ((numbuttons (%get-joystick-buttons joy buttons numbuttons
)))
863 (loop for i below numbuttons collecting
(mem-aref buttons
:unsigned-char i
)))))
866 (defcfun+doc
("glfwGetTime" get-time
) :double
()
868 The function returns the value of the high precision timer. The time is measured in seconds, and is
869 returned as a double precision floating point value.
872 The function returns the state of a high precision timer. Unless the timer has been set by the
873 glfwSetTime function, the time is measured as the number of seconds that have passed since glfwInit
877 The resolution of the timer depends on which system the program is running on. The worst case
878 resolution is somewhere in the order of 10 ms, while for most systems the resolution should be better
882 (defcfun+doc
("glfwSetTime" set-time
) :void
((time :double
))
885 Time (in seconds) that the timer should be set to.
888 The function sets the current time of the high precision timer to the specified time. Subsequent calls to
889 glfwGetTime will be relative to this time. The time is given in seconds.
892 (defcfun+doc
("glfwSleep" sleep
) :void
((time :double
))
895 Time, in seconds, to sleep.
898 The function puts the calling thread to sleep for the requested period of time. Only the calling thread is
899 put to sleep. Other threads within the same process can still execute.
902 There is usually a system dependent minimum time for which it is possible to sleep. This time is
903 generally in the range 1 ms to 20 ms, depending on thread sheduling time slot intervals etc. Using a
904 shorter time as a parameter to glfwSleep can give one of two results: either the thread will sleep for the
905 minimum possible sleep time, or the thread will not sleep at all (glfwSleep returns immediately). The
906 latter should only happen when very short sleep times are specified, if at all. ")
912 (bytes-per-pixel :int
)
915 (defcfun+doc
("glfwReadImage" read-image
) :int
916 ((name :string
) (img image
) (flags :int
))
919 A null terminated ISO 8859-1 string holding the name of the file that should be read.
921 Pointer to a GLFWimage struct, which will hold the information about the loaded image (if the
922 read was successful).
924 Flags for controlling the image reading process. Valid flags are listed in table 3.6
926 The function returns GL_TRUE if the image was loaded successfully. Otherwise GL_FALSE is
929 The function reads an image from the file specified by the parameter name and returns the image
930 information and data in a GLFWimage structure, which has the following definition:
933 int Width, Height; // Image dimensions
934 int Format; // OpenGL pixel format
935 int BytesPerPixel; // Number of bytes per pixel
936 unsigned char *Data; // Pointer to pixel data
939 Width and Height give the dimensions of the image. Format specifies an OpenGL™ pixel format,
940 which can be GL_LUMINANCE or GL_ALPHA (for gray scale images), GL_RGB or GL_RGBA.
941 BytesPerPixel specifies the number of bytes per pixel. Data is a pointer to the actual pixel data.
942 By default the read image is rescaled to the nearest larger 2m × 2n resolution using bilinear
943 interpolation, if necessary, which is useful if the image is to be used as an OpenGL™ texture. This
944 behavior can be disabled by setting the GLFW_NO_RESCALE_BIT flag.
945 Unless the flag GLFW_ORIGIN_UL_BIT is set, the first pixel in img->Data is the lower left corner of
946 the image. If the flag GLFW_ORIGIN_UL_BIT is set, however, the first pixel is the upper left corner.
947 For single component images (i.e. gray scale), Format is set to GL_ALPHA if the flag
948 GLFW_ALPHA_MAP_BIT flag is set, otherwise Format is set to GL_LUMINANCE.
950 glfwReadImage supports the Truevision Targa version 1 file format (.TGA). Supported pixel formats
951 are: 8-bit gray scale, 8-bit paletted (24/32-bit color), 24-bit true color and 32-bit true color + alpha.
952 Paletted images are translated into true color or true color + alpha pixel formats.
953 Please note that OpenGL™ 1.0 does not support single component alpha maps, so do not use images
954 with Format = GL_ALPHA directly as textures under OpenGL™ 1.0.
957 (defcfun+doc
("glfwReadMemoryImage" read-memory-image
) :int
958 ((data :pointer
) (size :long
) (img image
) (flags :int
))
961 The memory buffer holding the contents of the file that should be read.
963 The size, in bytes, of the memory buffer.
965 Pointer to a GLFWimage struct, which will hold the information about the loaded image (if the
966 read was successful).
968 Flags for controlling the image reading process. Valid flags are listed in table 3.6
970 The function returns GL_TRUE if the image was loaded successfully. Otherwise GL_FALSE is
973 The function reads an image from the memory buffer specified by the parameter data and returns the
974 image information and data in a GLFWimage structure, which has the following definition:
977 int Width, Height; // Image dimensions
978 int Format; // OpenGL pixel format
979 int BytesPerPixel; // Number of bytes per pixel
980 unsigned char *Data; // Pointer to pixel data
983 Width and Height give the dimensions of the image. Format specifies an OpenGL™ pixel format,
984 which can be GL_LUMINANCE or GL_ALPHA (for gray scale images), GL_RGB or GL_RGBA.
985 BytesPerPixel specifies the number of bytes per pixel. Data is a pointer to the actual pixel data.
986 By default the read image is rescaled to the nearest larger 2m × 2n resolution using bilinear
987 interpolation, if necessary, which is useful if the image is to be used as an OpenGL™ texture. This
988 behavior can be disabled by setting the GLFW_NO_RESCALE_BIT flag.
989 Unless the flag GLFW_ORIGIN_UL_BIT is set, the first pixel in img->Data is the lower left corner of
990 the image. If the flag GLFW_ORIGIN_UL_BIT is set, however, the first pixel is the upper left corner.
991 For single component images (i.e. gray scale), Format is set to GL_ALPHA if the flag
992 GLFW_ALPHA_MAP_BIT flag is set, otherwise Format is set to GL_LUMINANCE.
994 glfwReadMemoryImage supports the Truevision Targa version 1 file format (.TGA). Supported pixel
995 formats are: 8-bit gray scale, 8-bit paletted (24/32-bit color), 24-bit true color and 32-bit true color +
997 Paletted images are translated into true color or true color + alpha pixel formats.
998 Please note that OpenGL™ 1.0 does not support single component alpha maps, so do not use images
999 with Format = GL_ALPHA directly as textures under OpenGL™ 1.0.
1002 (defcfun+doc
("glfwFreeImage" free-image
) :void
((img image
))
1005 Pointer to a GLFWimage struct.
1007 The function frees any memory occupied by a loaded image, and clears all the fields of the GLFWimage
1008 struct. Any image that has been loaded by the glfwReadImage function should be deallocated using
1009 this function, once the image is not needed anymore. ")
1011 (defcfun+doc
("glfwLoadTexture2D" load-texture-2d
) :int
((name :string
) (flags :int
))
1014 An ISO 8859-1 string holding the name of the file that should be loaded.
1016 Flags for controlling the texture loading process. Valid flags are listed in table 3.7.
1018 The function returns GL_TRUE if the texture was loaded successfully. Otherwise GL_FALSE is
1022 The function reads an image from the file specified by the parameter name and uploads the image to
1023 OpenGL™ texture memory (using the glTexImage2D function).
1024 If the GLFW_BUILD_MIPMAPS_BIT flag is set, all mipmap levels for the loaded texture are
1025 generated and uploaded to texture memory.
1026 Unless the flag GLFW_ORIGIN_UL_BIT is set, the origin of the texture is the lower left corner of the
1027 loaded image. If the flag GLFW_ORIGIN_UL_BIT is set, however, the first pixel is the upper left
1029 For single component images (i.e. gray scale), the texture is uploaded as an alpha mask if the flag
1030 GLFW_ALPHA_MAP_BIT flag is set, otherwise it is uploaded as a luminance texture.
1033 glfwLoadTexture2D supports the Truevision Targa version 1 file format (.TGA). Supported pixel
1034 formats are: 8-bit gray scale, 8-bit paletted (24/32-bit color), 24-bit true color and 32-bit true color +
1036 Paletted images are translated into true color or true color + alpha pixel formats.
1037 The read texture is always rescaled to the nearest larger 2m × 2n resolution using bilinear interpolation,
1038 if necessary, since OpenGL™ requires textures to have a 2m × 2n resolution.
1039 If the GL_SGIS_generate_mipmap extension, which is usually hardware accelerated, is supported by
1040 the OpenGL™ implementation it will be used for mipmap generation. Otherwise the mipmaps will be
1041 generated by GLFW in software.
1042 Since OpenGL™ 1.0 does not support single component alpha maps, alpha map textures are converted
1043 to RGBA format under OpenGL™ 1.0 when the GLFW_ALPHA_MAP_BIT flag is set and the loaded
1044 texture is a single component texture. The red, green and blue components are set to 1.0.
1047 (defcfun+doc
("glfwLoadMemoryTexture2D" load-memory-texture-2d
) :int
1048 ((data :pointer
) (size :long
) (flags :int
))
1051 The memory buffer holding the contents of the file that should be loaded.
1053 The size, in bytes, of the memory buffer.
1055 Flags for controlling the texture loading process. Valid flags are listed in table 3.7.
1057 The function returns GL_TRUE if the texture was loaded successfully. Otherwise GL_FALSE is
1061 The function reads an image from the memory buffer specified by the parameter data and uploads the
1062 image to OpenGL™ texture memory (using the glTexImage2D function).
1063 If the GLFW_BUILD_MIPMAPS_BIT flag is set, all mipmap levels for the loaded texture are
1064 generated and uploaded to texture memory.
1065 Unless the flag GLFW_ORIGIN_UL_BIT is set, the origin of the texture is the lower left corner of the
1066 loaded image. If the flag GLFW_ORIGIN_UL_BIT is set, however, the first pixel is the upper left
1068 For single component images (i.e. gray scale), the texture is uploaded as an alpha mask if the flag
1069 GLFW_ALPHA_MAP_BIT flag is set, otherwise it is uploaded as a luminance texture.
1072 glfwLoadMemoryTexture2D supports the Truevision Targa version 1 file format (.TGA). Supported
1073 pixel formats are: 8-bit gray scale, 8-bit paletted (24/32-bit color), 24-bit true color and 32-bit true color
1075 Paletted images are translated into true color or true color + alpha pixel formats.
1076 The read texture is always rescaled to the nearest larger 2m × 2n resolution using bilinear interpolation,
1077 if necessary, since OpenGL™ requires textures to have a 2m × 2n resolution.
1078 If the GL_SGIS_generate_mipmap extension, which is usually hardware accelerated, is supported by
1079 the OpenGL™ implementation it will be used for mipmap generation. Otherwise the mipmaps will be
1080 generated by GLFW in software.
1081 Since OpenGL™ 1.0 does not support single component alpha maps, alpha map textures are converted
1082 to RGBA format under OpenGL™ 1.0 when the GLFW_ALPHA_MAP_BIT flag is set and the loaded
1083 texture is a single component texture. The red, green and blue components are set to 1.0.
1087 (defcfun+doc
("glfwLoadTextureImage2D" load-texture-image-2d
) :int
((img image
)
1091 Pointer to a GLFWimage struct holding the information about the image to be loaded.
1093 Flags for controlling the texture loading process. Valid flags are listed in table 3.7.
1095 The function returns GL_TRUE if the texture was loaded successfully. Otherwise GL_FALSE is
1099 The function uploads the image specified by the parameter img to OpenGL™ texture memory (using
1100 the glTexImage2D function).
1101 If the GLFW_BUILD_MIPMAPS_BIT flag is set, all mipmap levels for the loaded texture are
1102 generated and uploaded to texture memory.
1103 Unless the flag GLFW_ORIGIN_UL_BIT is set, the origin of the texture is the lower left corner of the
1104 loaded image. If the flag GLFW_ORIGIN_UL_BIT is set, however, the first pixel is the upper left
1106 For single component images (i.e. gray scale), the texture is uploaded as an alpha mask if the flag
1107 GLFW_ALPHA_MAP_BIT flag is set, otherwise it is uploaded as a luminance texture.
1110 glfwLoadTextureImage2D supports the Truevision Targa version 1 file format (.TGA). Supported
1111 pixel formats are: 8-bit gray scale, 8-bit paletted (24/32-bit color), 24-bit true color and 32-bit true color
1113 Paletted images are translated into true color or true color + alpha pixel formats.
1114 The read texture is always rescaled to the nearest larger 2m × 2n resolution using bilinear interpolation,
1115 if necessary, since OpenGL™ requires textures to have a 2m × 2n resolution.
1116 If the GL_SGIS_generate_mipmap extension, which is usually hardware accelerated, is supported by
1117 the OpenGL™ implementation it will be used for mipmap generation. Otherwise the mipmaps will be
1118 generated by GLFW in software.
1119 Since OpenGL™ 1.0 does not support single component alpha maps, alpha map textures are converted
1120 to RGBA format under OpenGL™ 1.0 when the GLFW_ALPHA_MAP_BIT flag is set and the loaded
1121 texture is a single component texture. The red, green and blue components are set to 1.0. ")
1124 (defcfun+doc
("glfwExtensionSupported" extension-supported
) :int
((extension :string
))
1127 A null terminated ISO 8859-1 string containing the name of an OpenGL™ extension.
1129 The function returns GL_TRUE if the extension is supported. Otherwise it returns GL_FALSE.
1131 The function does a string search in the list of supported OpenGL™ extensions to find if the specified
1132 extension is listed.
1134 An OpenGL™ context must be created before this function can be called (i.e. an OpenGL™ window
1135 must have been opened with glfwOpenWindow).
1136 In addition to checking for OpenGL™ extensions, GLFW also checks for extensions in the operating
1137 system “glue API”, such as WGL extensions under Windows and glX extensions under the X Window
1141 (defcfun+doc
("glfwGetProcAddress" get-proc-address
) :pointer
((procname :string
))
1144 A null terminated ISO 8859-1 string containing the name of an OpenGL™ extension function.
1146 The function returns the pointer to the specified OpenGL™ function if it is supported, otherwise
1149 The function acquires the pointer to an OpenGL™ extension function. Some (but not all) OpenGL™
1150 extensions define new API functions, which are usually not available through normal linking. It is
1151 therefore necessary to get access to those API functions at runtime.
1153 An OpenGL™ context must be created before this function can be called (i.e. an OpenGL™ window
1154 must have been opened with glfwOpenWindow).
1155 Some systems do not support dynamic function pointer retrieval, in which case glfwGetProcAddress
1156 will always return NULL.
1159 (defcfun+out
+doc
("glfwGetGLVersion" get-gl-version
) :void
((:out major
:int
)
1163 The function returns the major and minor version numbers and the revision for the currently used
1164 OpenGL™ implementation as a list (major minor rev).
1167 The function returns the OpenGL™ implementation version. This is a convenient function that parses
1168 the version number information from the string returned by calling
1169 glGetString( GL_VERSION ). The OpenGL™ version information can be used to determine
1170 what functionality is supported by the used OpenGL™ implementation.
1173 An OpenGL™ context must be created before this function can be called (i.e. an OpenGL™ window
1174 must have been opened with glfwOpenWindow). ")
1176 (defctype thread
:int
)
1177 (defctype threadfun
:pointer
)
1178 (defctype mutex
:pointer
)
1179 (defctype cond
:pointer
)
1181 (defcfun+doc
("glfwCreateThread" create-thread
) thread
((fun threadfun
) (arg :pointer
) )
1184 A pointer to a function that acts as the entry point for the new thread. The function should have
1185 the following C language prototype:
1186 void GLFWCALL functionname( void *arg );
1187 Where functionname is the name of the thread function, and arg is the user supplied argument
1190 An arbitrary argument for the thread. arg will be passed as the argument to the thread function
1191 pointed to by fun. For instance, arg can point to data that is to be processed by the thread.
1193 The function returns a thread identification number if the thread was created successfully. This number
1194 is always positive. If the function fails, a negative number is returned.
1196 The function creates a new thread, which executes within the same address space as the calling process.
1197 The thread entry point is specified with the fun argument.
1198 Once the thread function fun returns, the thread dies.
1200 Even if the function returns a positive thread ID, indicating that the thread was created successfully, the
1201 thread may be unable to execute, for instance if the thread start address is not a valid thread entry point.
1203 (defcfun+doc
("glfwDestroyThread" destroy-thread
) :void
((id thread
))
1206 A thread identification handle, which is returned by glfwCreateThread or glfwGetThreadID.
1208 The function kills a running thread and removes it from the thread list.
1210 This function is a very dangerous operation, which may interrupt a thread in the middle of an important
1211 operation, and its use is discouraged. You should always try to end a thread in a graceful way using
1212 thread communication, and use glfwWaitThread in order to wait for the thread to die.
1214 (defcfun+doc
("glfwWaitThread" wait-thread
) :int
((id thread
) (waitmode :int
) )
1217 A thread identification handle, which is returned by glfwCreateThread or glfwGetThreadID.
1219 Can be either GLFW_WAIT or GLFW_NOWAIT.
1221 The function returns GL_TRUE if the specified thread died after the function was called, or the thread
1222 did not exist, in which case glfwWaitThread will return immediately regardless of waitmode. The
1223 function returns GL_FALSE if waitmode is GLFW_NOWAIT, and the specified thread exists and is still
1226 (defcfun+doc
("glfwGetThreadID" get-thread-id
) thread
()
1228 The function returns a thread identification handle for the calling thread.
1230 The function determines the thread ID for the calling thread. The ID is the same value as was returned
1231 by glfwCreateThread when the thread was created.
1234 (defcfun+doc
("glfwCreateMutex" create-mutex
) mutex
()
1236 The function returns a mutex handle, or NULL if the mutex could not be created.
1238 The function creates a mutex object, which can be used to control access to data that is shared between
1241 (defcfun+doc
("glfwDestroyMutex" destroy-mutex
) :void
((mutex mutex
))
1244 A mutex object handle.
1246 The function destroys a mutex object. After a mutex object has been destroyed, it may no longer be
1249 (defcfun+doc
("glfwLockMutex" lock-mutex
) :void
((mutex mutex
))
1252 A mutex object handle.
1254 The function will acquire a lock on the selected mutex object. If the mutex is already locked by another
1255 thread, the function will block the calling thread until it is released by the locking thread. Once the
1256 function returns, the calling thread has an exclusive lock on the mutex. To release the mutex, call
1259 (defcfun+doc
("glfwUnlockMutex" unlock-mutex
) :void
((mutex mutex
))
1262 A mutex object handle.
1264 The function releases the lock of a locked mutex object.
1267 (defcfun+doc
("glfwCreateCond" create-cond
) cond
()
1269 The function returns a condition variable handle, or NULL if the condition variable could not be
1272 The function creates a condition variable object, which can be used to synchronize threads.
1274 (defcfun+doc
("glfwDestroyCond" destroy-cond
) :void
((cond cond
))
1277 A condition variable object handle.
1279 The function destroys a condition variable object. After a condition variable object has been destroyed,
1280 it may no longer be used by any thread.
1282 (defcfun+doc
("glfwWaitCond" wait-cond
) :void
((cond cond
) (mutex mutex
) (timeout :double
))
1285 A condition variable object handle.
1287 A mutex object handle.
1289 Maximum time to wait for the condition variable. The parameter can either be a positive time (in
1290 seconds), or GLFW_INFINITY.
1292 The function atomically unlocks the mutex specified by mutex, and waits for the condition variable cond
1293 to be signaled. The thread execution is suspended and does not consume any CPU time until the
1294 condition variable is signaled or the amount of time specified by timeout has passed. If timeout is
1295 GLFW_INFINITY, glfwWaitCond will wait forever for cond to be signaled. Before returning to the
1296 calling thread, glfwWaitCond automatically re-acquires the mutex.
1298 The mutex specified by mutex must be locked by the calling thread before entrance to glfwWaitCond.
1299 A condition variable must always be associated with a mutex, to avoid the race condition where a thread
1300 prepares to wait on a condition variable and another thread signals the condition just before the first
1301 thread actually waits on it.
1303 (defcfun+doc
("glfwSignalCond" signal-cond
) :void
((cond cond
))
1306 A condition variable object handle.
1308 The function restarts one of the threads that are waiting on the condition variable cond. If no threads are
1309 waiting on cond, nothing happens. If several threads are waiting on cond, exactly one is restarted, but it
1310 is not specified which.
1312 When several threads are waiting for the condition variable, which thread is started depends on
1313 operating system scheduling rules, and may vary from system to system and from time to time.
1315 (defcfun+doc
("glfwBroadcastCond" broadcast-cond
) :void
((cond cond
))
1318 A condition variable object handle.
1320 The function restarts all the threads that are waiting on the condition variable cond. If no threads are
1321 waiting on cond, nothing happens.
1323 When several threads are waiting for the condition variable, the order in which threads are started
1324 depends on operating system scheduling rules, and may vary from system to system and from time to
1328 (defcfun+doc
("glfwGetNumberOfProcessors" get-number-of-processors
) :int
()
1330 The function returns the number of active processors in the system.
1332 The function determines the number of active processors in the system.
1334 Systems with several logical processors per physical processor, also known as SMT (Symmetric Multi
1335 Threading) processors, will report the number of logical processors.
1337 (defcfun+doc
("glfwEnable" enable
) :void
((token :int
))
1340 A value specifying a feature to enable or disable. Valid tokens are listed in table 3.8.
1344 glfwEnable is used to enable a certain feature, while glfwDisable is used to disable it. Below follows a
1345 description of each feature.
1346 GLFW_AUTO_POLL_EVENTS
1347 When GLFW_AUTO_POLL_EVENTS is enabled, glfwPollEvents is automatically called each time
1348 that glfwSwapBuffers is called.
1349 When GLFW_AUTO_POLL_EVENTS is disabled, calling glfwSwapBuffers will not result in a call to
1350 glfwPollEvents. This can be useful if glfwSwapBuffers needs to be called from within a callback
1351 function, since calling glfwPollEvents from a callback function is not allowed.
1353 When GLFW_KEY_REPEAT is enabled, the key and character callback functions are called repeatedly
1354 when a key is held down long enough (according to the system key repeat configuration).
1355 When GLFW_KEY_REPEAT is disabled, the key and character callback functions are only called once
1356 when a key is pressed (and once when it is released).
1358 When GLFW_MOUSE_CURSOR is enabled, the mouse cursor is visible, and mouse coordinates are
1359 relative to the upper left corner of the client area of the GLFW window. The coordinates are limited to
1360 the client area of the window.
1361 When GLFW_MOUSE_CURSOR is disabled, the mouse cursor is invisible, and mouse coordinates are
1362 not limited to the drawing area of the window. It is as if the mouse coordinates are recieved directly
1363 from the mouse, without being restricted or manipulated by the windowing system.
1365 When GLFW_STICKY_KEYS is enabled, keys which are pressed will not be released until they are
1366 physically released and checked with glfwGetKey. This behavior makes it possible to catch keys that
1367 were pressed and then released again between two calls to glfwPollEvents, glfwWaitEvents or
1368 glfwSwapBuffers, which would otherwise have been reported as released. Care should be taken when
1369 using this mode, since keys that are not checked with glfwGetKey will never be released. Note also that
1370 enabling GLFW_STICKY_KEYS does not affect the behavior of the keyboard callback functionality.
1371 When GLFW_STICKY_KEYS is disabled, the status of a key that is reported by glfwGetKey is always
1372 the physical state of the key. Disabling GLFW_STICKY_KEYS also clears the sticky information for
1374 GLFW_STICKY_MOUSE_BUTTONS
1375 When GLFW_STICKY_MOUSE_BUTTONS is enabled, mouse buttons that are pressed will not be
1376 released until they are physically released and checked with glfwGetMouseButton. This behavior
1377 makes it possible to catch mouse buttons which were pressed and then released again between two calls
1378 to glfwPollEvents, glfwWaitEvents or glfwSwapBuffers, which would otherwise have been reported
1379 as released. Care should be taken when using this mode, since mouse buttons that are not checked with
1380 glfwGetMouseButton will never be released. Note also that enabling
1381 GLFW_STICKY_MOUSE_BUTTONS does not affect the behavior of the mouse button callback
1383 When GLFW_STICKY_MOUSE_BUTTONS is disabled, the status of a mouse button that is reported
1384 by glfwGetMouseButton is always the physical state of the mouse button. Disabling
1385 GLFW_STICKY_MOUSE_BUTTONS also clears the sticky information for all mouse buttons.
1387 When GLFW_SYSTEM_KEYS is enabled, pressing standard system key combinations, such as
1388 ALT+TAB under Windows, will give the normal behavior. Note that when ALT+TAB is issued under
1389 Windows in this mode so that the GLFW application is deselected when GLFW is operating in
1390 fullscreen mode, the GLFW application window will be minimized and the video mode will be set to
1391 the original desktop mode. When the GLFW application is re-selected, the video mode will be set to
1392 the GLFW video mode again.
1393 When GLFW_SYSTEM_KEYS is disabled, pressing standard system key combinations will have no
1394 effect, since those key combinations are blocked by GLFW. This mode can be useful in situations when
1395 the GLFW program must not be interrupted (normally for games in fullscreen mode).
1397 (defcfun+doc
("glfwDisable" disable
) :void
((token :int
))
1400 A value specifying a feature to enable or disable. Valid tokens are listed in table 3.8.
1404 glfwEnable is used to enable a certain feature, while glfwDisable is used to disable it. Below follows a
1405 description of each feature.
1406 GLFW_AUTO_POLL_EVENTS
1407 When GLFW_AUTO_POLL_EVENTS is enabled, glfwPollEvents is automatically called each time
1408 that glfwSwapBuffers is called.
1409 When GLFW_AUTO_POLL_EVENTS is disabled, calling glfwSwapBuffers will not result in a call to
1410 glfwPollEvents. This can be useful if glfwSwapBuffers needs to be called from within a callback
1411 function, since calling glfwPollEvents from a callback function is not allowed.
1413 When GLFW_KEY_REPEAT is enabled, the key and character callback functions are called repeatedly
1414 when a key is held down long enough (according to the system key repeat configuration).
1415 When GLFW_KEY_REPEAT is disabled, the key and character callback functions are only called once
1416 when a key is pressed (and once when it is released).
1418 When GLFW_MOUSE_CURSOR is enabled, the mouse cursor is visible, and mouse coordinates are
1419 relative to the upper left corner of the client area of the GLFW window. The coordinates are limited to
1420 the client area of the window.
1421 When GLFW_MOUSE_CURSOR is disabled, the mouse cursor is invisible, and mouse coordinates are
1422 not limited to the drawing area of the window. It is as if the mouse coordinates are recieved directly
1423 from the mouse, without being restricted or manipulated by the windowing system.
1425 When GLFW_STICKY_KEYS is enabled, keys which are pressed will not be released until they are
1426 physically released and checked with glfwGetKey. This behavior makes it possible to catch keys that
1427 were pressed and then released again between two calls to glfwPollEvents, glfwWaitEvents or
1428 glfwSwapBuffers, which would otherwise have been reported as released. Care should be taken when
1429 using this mode, since keys that are not checked with glfwGetKey will never be released. Note also that
1430 enabling GLFW_STICKY_KEYS does not affect the behavior of the keyboard callback functionality.
1431 When GLFW_STICKY_KEYS is disabled, the status of a key that is reported by glfwGetKey is always
1432 the physical state of the key. Disabling GLFW_STICKY_KEYS also clears the sticky information for
1434 GLFW_STICKY_MOUSE_BUTTONS
1435 When GLFW_STICKY_MOUSE_BUTTONS is enabled, mouse buttons that are pressed will not be
1436 released until they are physically released and checked with glfwGetMouseButton. This behavior
1437 makes it possible to catch mouse buttons which were pressed and then released again between two calls
1438 to glfwPollEvents, glfwWaitEvents or glfwSwapBuffers, which would otherwise have been reported
1439 as released. Care should be taken when using this mode, since mouse buttons that are not checked with
1440 glfwGetMouseButton will never be released. Note also that enabling
1441 GLFW_STICKY_MOUSE_BUTTONS does not affect the behavior of the mouse button callback
1443 When GLFW_STICKY_MOUSE_BUTTONS is disabled, the status of a mouse button that is reported
1444 by glfwGetMouseButton is always the physical state of the mouse button. Disabling
1445 GLFW_STICKY_MOUSE_BUTTONS also clears the sticky information for all mouse buttons.
1447 When GLFW_SYSTEM_KEYS is enabled, pressing standard system key combinations, such as
1448 ALT+TAB under Windows, will give the normal behavior. Note that when ALT+TAB is issued under
1449 Windows in this mode so that the GLFW application is deselected when GLFW is operating in
1450 fullscreen mode, the GLFW application window will be minimized and the video mode will be set to
1451 the original desktop mode. When the GLFW application is re-selected, the video mode will be set to
1452 the GLFW video mode again.
1453 When GLFW_SYSTEM_KEYS is disabled, pressing standard system key combinations will have no
1454 effect, since those key combinations are blocked by GLFW. This mode can be useful in situations when
1455 the GLFW program must not be interrupted (normally for games in fullscreen mode).