summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2021-08-06 08:57:39 -0400
committerDavid Thompson <dthompson2@worcester.edu>2021-08-06 08:57:39 -0400
commitbb6184dbba414ea475bd97c737b6d81510257ddf (patch)
treee6232a90dd65380826bf479f421cc9d528a78e88
parent2adf8c644592230bc0f8bbc511a514f28cb4f7f5 (diff)
graphics: texture: Add support for mipmaps.
-rw-r--r--chickadee/graphics/texture.scm19
1 files changed, 17 insertions, 2 deletions
diff --git a/chickadee/graphics/texture.scm b/chickadee/graphics/texture.scm
index e7342db..5b46af1 100644
--- a/chickadee/graphics/texture.scm
+++ b/chickadee/graphics/texture.scm
@@ -202,7 +202,15 @@ Currently only 32-bit RGBA format is supported."
(texture-parameter-name texture-min-filter)
(match min-filter
('nearest (gl:texture-min-filter nearest))
- ('linear (gl:texture-min-filter linear))))
+ ('linear (gl:texture-min-filter linear))
+ ('nearest-mipmap-nearest
+ (gl:texture-min-filter nearest-mipmap-nearest))
+ ('linear-mipmap-nearest
+ (gl:texture-min-filter linear-mipmap-nearest))
+ ('nearest-mipmap-linear
+ (gl:texture-min-filter nearest-mipmap-linear))
+ ('linear-mipmap-linear
+ (gl:texture-min-filter linear-mipmap-linear))))
(gl-texture-parameter (texture-target texture-2d)
(texture-parameter-name texture-mag-filter)
(match mag-filter
@@ -219,7 +227,14 @@ Currently only 32-bit RGBA format is supported."
(match format
('rgba (pixel-format rgba)))
(color-pointer-type unsigned-byte)
- (or pixels %null-pointer)))
+ (or pixels %null-pointer))
+ ;; Generate mipmaps, if needed.
+ (when (memq min-filter
+ '(nearest-mipmap-nearest
+ linear-mipmap-nearest
+ nearest-mipmap-linear
+ linear-mipmap-linear))
+ (gl-generate-mipmap (texture-target texture-2d))))
texture))
(define (make-texture-region texture rect)