summaryrefslogtreecommitdiff
path: root/2d
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@member.fsf.org>2013-08-04 22:59:29 -0400
committerDavid Thompson <dthompson@member.fsf.org>2013-08-04 22:59:29 -0400
commitbdee8563b02a087d17f57c2536bd3b1eef721eaa (patch)
treebcdb556e454efd17e414f1b6b1535d1e339354f5 /2d
parent4cddff4b185418c025e68ee5334ef1c541246240 (diff)
Ensure that all texture objects are added to the texture guardian.
Diffstat (limited to '2d')
-rw-r--r--2d/texture.scm19
1 files changed, 11 insertions, 8 deletions
diff --git a/2d/texture.scm b/2d/texture.scm
index 28b6482..06e127f 100644
--- a/2d/texture.scm
+++ b/2d/texture.scm
@@ -52,7 +52,7 @@
;; The <texture> object is a simple wrapper around an OpenGL texture
;; id.
(define-record-type <texture>
- (make-texture id parent width height s1 t1 s2 t2)
+ (%make-texture id parent width height s1 t1 s2 t2)
texture?
(id texture-id)
(parent texture-parent)
@@ -66,6 +66,11 @@
(define (texture-region? texture)
(texture? (texture-parent texture)))
+(define (make-texture id parent width height s1 t1 s2 t2)
+ (let ((texture (%make-texture id parent width height s1 t1 s2 t2)))
+ (texture-guardian texture)
+ texture))
+
(define (make-texture-region texture x y width height)
"Creates a new texture region given a texture and a pixel region."
(let* ((w (texture-width texture))
@@ -127,13 +132,11 @@ Currently only works with RGBA format surfaces."
pixel-format
(color-pointer-type unsigned-byte)
(SDL:surface-pixels surface)))
- (let ((texture (make-texture texture-id
- #f
- (SDL:surface:w surface)
- (SDL:surface:h surface)
- 0 0 1 1)))
- (texture-guardian texture)
- texture)))
+ (make-texture texture-id
+ #f
+ (SDL:surface:w surface)
+ (SDL:surface:h surface)
+ 0 0 1 1)))
(define (load-texture filename)
"Loads a texture from a file."