From 7d7a8f9e77a526fd5f2920b9005805e56a4b686c Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 10 Dec 2014 19:39:38 +0200 Subject: [PATCH] Use explicit mipmap generation if necessary --- source/resources.cpp | 3 ++- source/texture.cpp | 14 +++++++++++++- source/texture.h | 4 ++++ source/texture1d.cpp | 1 + source/texture2d.cpp | 1 + source/texture3d.cpp | 1 + source/texturecube.cpp | 2 ++ 7 files changed, 24 insertions(+), 2 deletions(-) diff --git a/source/resources.cpp b/source/resources.cpp index 2fd69503..afb84b27 100644 --- a/source/resources.cpp +++ b/source/resources.cpp @@ -1,4 +1,5 @@ #include +#include #include "animation.h" #include "armature.h" #include "font.h" @@ -20,7 +21,7 @@ namespace Msp { namespace GL { Resources::Resources(): - default_tex_filter(LINEAR_MIPMAP_LINEAR), + default_tex_filter(SGIS_generate_mipmap ? LINEAR_MIPMAP_LINEAR : LINEAR), srgb_conversion(false), resource_manager(0) { diff --git a/source/texture.cpp b/source/texture.cpp index 81373c97..22bdebdf 100644 --- a/source/texture.cpp +++ b/source/texture.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -168,7 +169,18 @@ void Texture::set_generate_mipmap(bool gm) if(gm) static Require _req(SGIS_generate_mipmap); gen_mipmap = gm; - update_parameter(GENERATE_MIPMAP); + if(get_gl_api()!=OPENGL_ES2) + update_parameter(GENERATE_MIPMAP); +} + +void Texture::auto_generate_mipmap() +{ + if(get_gl_api()==OPENGL_ES2) + { + // glGenerateMipmap is defined here + static Require _req(EXT_framebuffer_object); + glGenerateMipmap(target); + } } void Texture::set_compare_enabled(bool c) diff --git a/source/texture.h b/source/texture.h index 79d79dbd..db6165fe 100644 --- a/source/texture.h +++ b/source/texture.h @@ -144,6 +144,10 @@ public: when a texture image is uploaded. */ void set_generate_mipmap(bool); +protected: + void auto_generate_mipmap(); + +public: /** Sets depth texture comparison. Has no effect on other formats. When comparison is enabled, the third component of the texture coordinate is compared against the texel value, and the result is returned as the texture diff --git a/source/texture1d.cpp b/source/texture1d.cpp index a0876ace..accd0e0c 100644 --- a/source/texture1d.cpp +++ b/source/texture1d.cpp @@ -50,6 +50,7 @@ void Texture1D::image(unsigned level, PixelFormat fmt, DataType type, const void allocated |= 1<>=1, ++level) ; allocated |= (1<>=1, h>>=1, ++level) ; allocated |= (1<>=1, h>>=1, d>>=1, ++level) ; allocated |= (1<>=1, ++level) ; allocated |= (1<