Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (ql:quickload (list :cl-glfw3 :cl-opengl :trivial-main-thread))
- (defpackage my-package
- (:use :cl :trivial-main-thread))
- (in-package :my-package)
- ;;;; basic-window.lisp
- ;;;; OpenGL example code borrowed from cl-opengl
- (glfw:def-key-callback quit-on-escape (window key scancode action mod-keys)
- (declare (ignore window scancode mod-keys))
- (when (and (eq key :escape) (eq action :press))
- (glfw:set-window-should-close)))
- (defun render()
- (gl:clear-color 0.5 0.5 0.5 0.5)
- t)
- (defun basic-window-example ()
- ;; Graphics calls on OS X must occur in the main thread
- (with-body-in-main-thread ()
- ; Comment the following 3 lines, and running this snippet shows a window
- (%glfw:window-hint :opengl-profile :opengl-core-profile)
- (%glfw:window-hint :context-version-major 4)
- (%glfw:window-hint :context-version-minor 6)
- (glfw:with-init-window (:title "Window test" :width 600 :height 400)
- (setf %gl:*gl-get-proc-address* #'glfw:get-proc-address)
- (glfw:set-key-callback 'quit-on-escape)
- (gl:viewport 0 0 600 400)
- (loop until (glfw:window-should-close-p)
- do (render)
- do (glfw:swap-buffers)
- do (glfw:poll-events)))))
- (basic-window-example)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement