Compiled meshes work
[lambdamundo.git] / window.lisp
blobdeec5eab2b4ac20c9acb90c79860a6f4e4e7cf3a
1 (in-package :lambdamundo)
3 ;; called when window is resized
6 (defmacro with-lambdamundo-window ((title &key
7 (dimensions '(0 0))
8 (colourbits '(:redbits 0 :greenbits 0 :bluebits 0 :alphabits 0))
9 (depthbits 32)
10 (stencilbits 0)
11 (mode glfw:+window+))
12 &body forms)
13 "Top level form for managing our window."
14 (destructuring-bind (width height)
15 dimensions
16 (destructuring-bind (redbits greenbits bluebits alphabits)
17 colourbits
18 (destructuring-bind (&key pre start main end
19 key-callback
20 resize-callback
21 char-callback
22 mouse-callback)
23 forms
24 `(progn
25 ,(when pre
26 `(progn ,@pre))
27 (glfw:with-init-window (,title ,width ,height ,redbits ,greenbits ,bluebits ,alphabits ,depthbits ,stencilbits ,mode)
28 ,@start
29 ,(when mouse-callback
30 `(glfw:set-mouse-button-callback (cffi:callback ,mouse-callback)))
31 ,(when key-callback
32 `(glfw:set-key-callback (cffi:callback ,key-callback)))
33 ,(when resize-callback
34 `(glfw:set-window-size-callback (cffi:callback ,resize-callback)))
35 ,(when char-callback
36 `(glfw:set-char-callback (cffi:callback ,char-callback)))
37 (iterate
38 ,@main
39 (glfw:swap-buffers)
40 (while (eql (glfw:get-window-param glfw:+opened+) gl:+true+)))
41 ,@end))))))