;;; 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))
(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)))))
(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)))))))))
(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)))))))