Advertisement
Guest User

cl-glfw3 `window-hint` problem

a guest
Feb 10th, 2022
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 1.23 KB | None | 0 0
  1. (ql:quickload (list :cl-glfw3 :cl-opengl :trivial-main-thread))
  2.  
  3. (defpackage my-package
  4.   (:use :cl :trivial-main-thread))
  5.  
  6. (in-package :my-package)
  7.  
  8. ;;;; basic-window.lisp
  9. ;;;; OpenGL example code borrowed from cl-opengl
  10.  
  11. (glfw:def-key-callback quit-on-escape (window key scancode action mod-keys)
  12.   (declare (ignore window scancode mod-keys))
  13.   (when (and (eq key :escape) (eq action :press))
  14.     (glfw:set-window-should-close)))
  15.  
  16. (defun render()
  17.   (gl:clear-color 0.5 0.5 0.5 0.5)
  18.   t)
  19.  
  20. (defun basic-window-example ()
  21.   ;; Graphics calls on OS X must occur in the main thread
  22.   (with-body-in-main-thread ()
  23.     ; Comment the following 3 lines, and running this snippet shows a window
  24.     (%glfw:window-hint :opengl-profile :opengl-core-profile)
  25.     (%glfw:window-hint :context-version-major 4)
  26.     (%glfw:window-hint :context-version-minor 6)
  27.     (glfw:with-init-window (:title "Window test" :width 600 :height 400)
  28.       (setf %gl:*gl-get-proc-address* #'glfw:get-proc-address)
  29.       (glfw:set-key-callback 'quit-on-escape)
  30.       (gl:viewport 0 0 600 400)
  31.       (loop until (glfw:window-should-close-p)
  32.          do (render)
  33.          do (glfw:swap-buffers)
  34.          do (glfw:poll-events)))))
  35.  
  36.  
  37. (basic-window-example)
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement