- (defun set-resource (type object &rest key)
- (let ((res
- (cond ((surface-p object)
- (make-resource :address (surface-address object)
- :free-function #'SDL_FreeSurface
- :object object))
- ((font-p object)
- (make-resource :address (font-address object)
- :free-function #'TTF_CloseFont
- :object object))
- ((cp-space-p object)
- (make-resource :address (cp-space-address object)
- :free-function #'cpSpaceFree
- :object object))
- ((cp-body-p object)
- (make-resource :address (cp-body-address object)
- :free-function #'cpBodyFree
- :object object))
- ((cp-shape-p object)
- (make-resource :address (cp-shape-address object)
- :free-function #'cpShapeFree
- :object object))
- (t nil))))
- (cond (res (setf (gethash `(,type ,@key) resources-table) res)))))
-
- (defun get-resource (type &rest key)
- (let ((resource (gethash `(,type ,@key) resources-table)))
+ (defun set-resource (key plist free-function &key static)
+ (setf (gethash key resources-table)
+ (make-resource :plist plist
+ :free-function free-function
+ :time (if static -1 (SDL_GetTicks)))))
+
+ (defun get-resource (key)
+ (let ((resource (gethash key resources-table)))