Skip to content

Instantly share code, notes, and snippets.

@jl2
Created October 26, 2020 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jl2/4f7d25b715badf2d322754a8bc690bef to your computer and use it in GitHub Desktop.
Save jl2/4f7d25b715badf2d322754a8bc690bef to your computer and use it in GitHub Desktop.
(ql:quickload :cl-glfw3)
(glfw:def-key-callback keyboard-handler (window key scancode action mod-keys)
(format t "Window ~a key ~a scancode ~a action ~a mod-keys ~a~%" window key scancode action mod-keys)
(when (eq key :escape)
(glfw:set-window-should-close window)))
(defun show-window (name)
(let ((win (glfw:create-window :title (format nil "GLFW Window (~a)" name)
:width 100
:height 100
:decorated nil
:opengl-profile :opengl-core-profile
:context-version-major 4
:context-version-minor 0
:opengl-forward-compat nil
:resizable t)))
(unwind-protect
(progn
(glfw:set-key-callback 'keyboard-handler win)
(loop
until (glfw:window-should-close-p win)
do
(glfw:swap-buffers win)
(glfw:poll-events)))
(glfw:destroy-window win))))
(defun test-create-window ()
"Create three windows in three threads."
(glfw:initialize)
(bt:make-thread (lambda () (show-window "test-0")) :name "test-0")
(bt:make-thread (lambda () (show-window "test-1")) :name "test-1")
(bt:make-thread (lambda () (show-window "test-2")) :name "test-2"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment