aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gl/util.lisp
blob: bff2f889933d6cb18f0b4caf7a7027220f2626f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
;;;; gl/util.lisp

(in-package #:wheelwork)

(define-symbol-macro +float-size+
    (cffi:foreign-type-size :float))

(defun gl-array (type &rest contents)
  (let ((array (gl:alloc-gl-array type (length contents))))
    (dotimes (i (length contents) array)
      (setf (gl:glaref array i) (elt contents i)))))

(defmacro with-gl-array ((var type &rest contents) &body body)
  `(let ((,var (gl-array ,type ,@contents))) 
     (unwind-protect (progn ,@body)
       (gl:free-gl-array ,var))))