From bb6184dbba414ea475bd97c737b6d81510257ddf Mon Sep 17 00:00:00 2001 From: David Thompson Date: Fri, 6 Aug 2021 08:57:39 -0400 Subject: graphics: texture: Add support for mipmaps. --- chickadee/graphics/texture.scm | 19 +++++++++++++++++-- 1 file 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) -- cgit v1.2.3