From: Julian Squires Date: Mon, 3 Nov 2008 03:44:18 +0000 (-0500) Subject: Improved GEN-IMAGES interface; fixed load problems. X-Git-Url: https://repo.or.cz/w/cl-devil.git/commitdiff_plain/5898e1d4dca6bf9ded6611c5b1968adea1667129 Improved GEN-IMAGES interface; fixed load problems. --- diff --git a/cl-devil.asd b/cl-devil.asd index 277d810..11f6460 100644 --- a/cl-devil.asd +++ b/cl-devil.asd @@ -5,7 +5,7 @@ (in-package #:cl-devil-system) (defsystem cl-devil - :depends-on (:cffi) + :depends-on (:cffi :anaphora) :components ((:file "package") (:file "il" :depends-on ("package")) diff --git a/il.lisp b/il.lisp index c93f76c..0884051 100644 --- a/il.lisp +++ b/il.lisp @@ -128,7 +128,7 @@ (defcfun ("ilInit" init) :void) (defcfun ("ilShutDown" shutdown) :void) -(defcfun ("ilGenImages" gen-images) :void (num :int) (images :pointer)) +(defcfun ("ilGenImages" %gen-images) :void (num :int) (images :pointer)) (defcfun ("ilBindImage" bind-image) :void (image :int)) (defcfun ("ilDeleteImages" delete-images) :void (num :int) (images :pointer)) (defcfun ("ilLoadImage" load-image) :boolean (file-name :string)) diff --git a/utilities.lisp b/utilities.lisp index 093eff5..d0b5a9e 100644 --- a/utilities.lisp +++ b/utilities.lisp @@ -24,7 +24,7 @@ (let (,@(loop for x in images for (var . args) = (if (listp x) x (list x)) for i from 0 - collect `(,var (anaphora:aprog1 (cffi:mem-ref ,ids :uint ,i) + collect `(,var (anaphora:aprog1 (cffi:mem-aref ,ids :uint ,i) ,@(w-i-args-helper args))))) ,@body) (il:delete-images ,count ,ids))))) @@ -43,7 +43,12 @@ (get-integer :image-height)) -(defmacro with-bound-image ((id) &body body) +(defun gen-images (n) + (with-foreign-object (ids :uint n) + (%gen-images n ids) + (loop for i to n collect (mem-aref ids :uint i)))) + +(defmacro with-bound-image (id &body body) "Binds ID for the duration of BODY, returning to the previously bound image thereafter." (let ((old-image (gensym))) `(let ((,old-image (il:get-integer :cur-image)))