From: jsancho Date: Sun, 11 Oct 2009 10:17:26 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=c31ef82b8f98c9011aa5a80777ad374566d743aa;p=gacela.git --- diff --git a/gacela.lisp b/gacela.lisp index 45df43c..8cd0da8 100644 --- a/gacela.lisp +++ b/gacela.lisp @@ -156,7 +156,7 @@ ;;; Resources Manager -(defstruct resource plist free-function time) +(defstruct resource plist constructor destructor time) (defun make-resource-texture (&key filename min-filter mag-filter) `(:type texture :filename ,filename :min-filter ,min-filter :mag-filter ,mag-filter)) @@ -166,9 +166,11 @@ (let ((resources-table (make-hash-table :test 'equal))) - (defun set-resource (key plist free-function &key static) + (defun set-resource (key plist constructor destructor &key static) (setf (gethash key resources-table) (make-resource :plist plist + :constructor constructor + :destructor destructor :free-function free-function :time (if static -1 (SDL_GetTicks))))) diff --git a/gacela_draw.lisp b/gacela_draw.lisp index 79c3edb..4c96b58 100644 --- a/gacela_draw.lisp +++ b/gacela_draw.lisp @@ -92,6 +92,7 @@ (SDL_FreeSurface image) (set-resource key `(:id-texture ,texture :width ,real-w :height ,real-h) + (lambda () (load-texture filename :min-filter min-filter :mag-filter mag-filter :static static)) (lambda () (glDeleteTextures 1 `(,texture))) :static static) key))))))))) diff --git a/gacela_ttf.lisp b/gacela_ttf.lisp index 6fbe4e5..0077ad4 100644 --- a/gacela_ttf.lisp +++ b/gacela_ttf.lisp @@ -26,6 +26,7 @@ (ftglSetFontCharMap font encoding) (set-resource key `(:id-font ,font) + (lambda () (open-font font-file :size size :encoding encoding :static static)) (lambda () (ftglDestroyFont font)) :static static) key)))))))