]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texture.cpp
Prefer explicit mipmap generation with glGenerateMipmap
[libs/gl.git] / source / texture.cpp
index 004d78c2abc38d1b9bc383b361cefae647b8ac06..fe27a04d9ddd830fa93f21d51052ec0ffc0da8cd 100644 (file)
@@ -78,7 +78,7 @@ Texture::~Texture()
 
 DataType Texture::get_alloc_type(PixelFormat fmt)
 {
-       return (fmt==DEPTH_COMPONENT ? UNSIGNED_SHORT : UNSIGNED_BYTE);
+       return (get_base_pixelformat(fmt)==DEPTH_COMPONENT ? UNSIGNED_SHORT : UNSIGNED_BYTE);
 }
 
 void Texture::update_parameter(int mask) const
@@ -172,21 +172,18 @@ void Texture::set_wrap_r(TextureWrap w)
 
 void Texture::set_generate_mipmap(bool gm)
 {
-       if(gm)
+       if(gm && !EXT_framebuffer_object)
                static Require _req(SGIS_generate_mipmap);
        gen_mipmap = gm;
-       if(get_gl_api()!=OPENGL_ES2)
+       if(!EXT_framebuffer_object)
                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 is defined here
+       if(EXT_framebuffer_object)
                glGenerateMipmap(target);
-       }
 }
 
 void Texture::set_compare_enabled(bool c)
@@ -364,5 +361,12 @@ void Texture::Loader::wrap_t(TextureWrap w)
        obj.set_wrap_t(w);
 }
 
+
+bool is_mipmapped(TextureFilter filter)
+{
+       return (filter==NEAREST_MIPMAP_NEAREST || filter==NEAREST_MIPMAP_LINEAR ||
+               filter==LINEAR_MIPMAP_NEAREST || filter==LINEAR_MIPMAP_LINEAR);
+}
+
 } // namespace GL
 } // namespace Msp