diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-12-24 14:46:05 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-12-24 14:46:05 +0000 |
commit | e10f427c49c1115f22067c81519f990ef213c9af (patch) | |
tree | aa95bac64a4b56db32354f087ef36ec7cf44ee72 /gfx/models | |
parent | Set surface from all triangles, not just the first (diff) | |
download | ilt-e10f427c49c1115f22067c81519f990ef213c9af.tar.bz2 ilt-e10f427c49c1115f22067c81519f990ef213c9af.tar.xz ilt-e10f427c49c1115f22067c81519f990ef213c9af.zip |
Generate mipmaps if min/mag filter settings use them
Diffstat (limited to 'gfx/models')
-rw-r--r-- | gfx/models/texture.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gfx/models/texture.cpp b/gfx/models/texture.cpp index a508421..3457fb5 100644 --- a/gfx/models/texture.cpp +++ b/gfx/models/texture.cpp @@ -50,6 +50,16 @@ Texture::Texture(GLsizei width, GLsizei height, const void * data, TextureOption glTexParameter(type, GL_TEXTURE_MIN_FILTER, to.minFilter); glTexParameter(type, GL_TEXTURE_MAG_FILTER, to.magFilter); glTexImage2D(type, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); + auto isMimmap = [](auto value) { + auto eqAnyOf = [value](auto... test) { + return (... || (value == test)); + }; + return eqAnyOf( + GL_NEAREST_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_LINEAR); + }; + if (isMimmap(to.minFilter) || isMimmap(to.magFilter)) { + glGenerateMipmap(type); + } } void |