From 75790be2d59f39f4d82f65b23b9a6e1a3127fab9 Mon Sep 17 00:00:00 2001 From: Paul Melis Date: Mon, 3 Jun 2024 20:35:45 +0200 Subject: [PATCH] Add GenModelMipmaps() for generating mipmaps (and setting texture filter) for all textures used by a Model --- src/rtextures.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/rtextures.c b/src/rtextures.c index 2f02afece..5a3fd6e2f 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -4029,6 +4029,20 @@ void GenTextureMipmaps(Texture2D *texture) rlGenTextureMipmaps(texture->id, texture->width, texture->height, texture->format, &texture->mipmaps); } +// Generate GPU mipmaps for all textures used in a model +void GenModelMipmaps(Model model) +{ + for (int i = 0; i < model.materialCount; i++) + { + Material *material = &(model.materials[i]); + for (int m = 0; m < MAX_MATERIAL_MAPS; m++) + { + GenTextureMipmaps(&(material->maps[m].texture)); + SetTextureFilter(material->maps[m].texture, TEXTURE_FILTER_TRILINEAR); + } + } +} + // Set texture scaling filter mode void SetTextureFilter(Texture2D texture, int filter) {