stoe/engine/gl-utils.lisp
Renaud Casenave-Péré 53de3d0cf6 Wrap glop functions in a viewport file
regroup opengl version and window creation and event polling in the
viewport file.
To further clean up the files layout, move input.lisp to engine folder
gl-utils is now used for some simple macros
2015-12-27 17:09:05 +01:00

32 lines
858 B
Common Lisp

#|
This file is a part of stoe project.
Copyright (c) 2015 Renaud Casenave-Péré (renaud@casenave-pere.fr)
|#
(uiop:define-package :stoe/engine/gl-utils
(:use :cl)
(:export #:gl-assert
#:gl-restart
#:size-of))
(in-package :stoe/engine/gl-utils)
(defmacro gl-assert (&body body)
`(progn
,@(loop for form in body
collect `(prog1
,form
(let ((err-sym (%gl:get-error)))
(unless (eq err-sym :zero)
(error "The OpenGL command `~a'~%~2iresulted in an error: ~s~%"
',form err-sym)))))))
(defmacro gl-restart (form)
`(restart-case
(gl-assert ,form)
(continue () :report "Continue")))
(defun size-of (type)
(ecase type
(:byte 1)
(:unsigned-short 2)
(:float 4)))