feature/resource-texture-drawing #24
1 changed files with 25 additions and 0 deletions
25
engine/resource.scm
Normal file
25
engine/resource.scm
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
(module (engine resource) ()
|
||||
(import scheme
|
||||
(chicken base)
|
||||
(chicken gc)
|
||||
raylib
|
||||
(srfi 99))
|
||||
|
||||
(define-record-type <resource>
|
||||
(int:make-resource type struct)
|
||||
resource?
|
||||
(type int:resource-type)
|
||||
(struct int:resource-contents))
|
||||
|
||||
(define (resource-finalizer type)
|
||||
(case type
|
||||
((font) unload-font)
|
||||
(else identity)))
|
||||
|
||||
(define (make-resource type struct)
|
||||
(assert (member type '(texture font)))
|
||||
(assert (record? struct))
|
||||
(let ((r (int:make-resource type struct)))
|
||||
(set-finalizer! r (lambda (x) ((resource-finalizer type) x)))))
|
||||
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue