]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texture.cpp
Remove support for legacy OpenGL features
[libs/gl.git] / source / texture.cpp
index f1689145c8af9c5754569213a7561b0505e63b2c..a7e4898c1edae7d73de8efe9bf425dbb69ccc569 100644 (file)
@@ -4,7 +4,6 @@
 #include <msp/gl/extensions/ext_framebuffer_object.h>
 #include <msp/gl/extensions/ext_texture3d.h>
 #include <msp/gl/extensions/ext_texture_filter_anisotropic.h>
-#include <msp/gl/extensions/sgis_generate_mipmap.h>
 #include <msp/io/memory.h>
 #include <msp/strings/format.h>
 #include "bindable.h"
@@ -69,7 +68,7 @@ Texture::Texture(GLenum t, ResourceManager *m):
        wrap_s(REPEAT),
        wrap_t(REPEAT),
        wrap_r(REPEAT),
-       auto_gen_mipmap(0),
+       auto_gen_mipmap(false),
        compare(false),
        cmp_func(LEQUAL),
        dirty_params(0)
@@ -104,12 +103,12 @@ void Texture::set_internal_format(PixelFormat fmt)
        FormatSwizzle swiz = NO_SWIZZLE;
        if(ARB_texture_rg && ARB_texture_swizzle)
        {
-               if(fmt==LUMINANCE8 || fmt==SLUMINANCE8)
+               if(fmt==LUMINANCE8)
                {
                        fmt = R8;
                        swiz = R_TO_LUMINANCE;
                }
-               else if(fmt==LUMINANCE8_ALPHA8 || fmt==SLUMINANCE8_ALPHA8)
+               else if(fmt==LUMINANCE8_ALPHA8)
                {
                        fmt = RG8;
                        swiz = RG_TO_LUMINANCE_ALPHA;
@@ -157,8 +156,6 @@ void Texture::update_parameter(int mask) const
                set_parameter_i(GL_TEXTURE_WRAP_T, wrap_t);
        if(mask&WRAP_R)
                set_parameter_i(GL_TEXTURE_WRAP_R, wrap_r);
-       if(mask&GENERATE_MIPMAP)
-               set_parameter_i(GL_GENERATE_MIPMAP, auto_gen_mipmap!=0);
        if(mask&COMPARE)
                set_parameter_i(GL_TEXTURE_COMPARE_MODE, (compare ? GL_COMPARE_R_TO_TEXTURE : GL_NONE));
        if(mask&COMPARE_FUNC)
@@ -264,7 +261,7 @@ void Texture::set_wrap_r(TextureWrap w)
 
 bool Texture::can_generate_mipmap()
 {
-       return (EXT_framebuffer_object || SGIS_generate_mipmap);
+       return EXT_framebuffer_object;
 }
 
 void Texture::generate_mipmap()
@@ -283,16 +280,10 @@ void Texture::generate_mipmap()
 
 void Texture::set_auto_generate_mipmap(bool gm)
 {
-       if(EXT_framebuffer_object)
-               auto_gen_mipmap = gm;
-       else
-       {
-               if(gm)
-                       static Require _req(SGIS_generate_mipmap);
+       if(gm)
+               static Require _req(EXT_framebuffer_object);
 
-               auto_gen_mipmap = gm*2;
-               update_parameter(GENERATE_MIPMAP);
-       }
+       auto_gen_mipmap = gm;
 }
 
 void Texture::set_compare_enabled(bool c)
@@ -318,7 +309,7 @@ void Texture::load_image(const string &fn, bool srgb)
        image(img, srgb);
 }
 
-void Texture::bind_to(unsigned i, bool legacy) const
+void Texture::bind_to(unsigned i) const
 {
        if(!id)
        {
@@ -331,28 +322,17 @@ void Texture::bind_to(unsigned i, bool legacy) const
                }
        }
 
-       legacy = (legacy && is_legacy_target(target));
-
        TexUnit &unit = TexUnit::get_unit(i);
-       const Texture *old = unit.get_texture();
-       bool old_legacy = unit.get_texture_legacy();
-       if(unit.set_texture(this, legacy))
+       if(unit.set_texture(this))
        {
                if(manager)
                        manager->resource_used(*this);
 
-               if(ARB_direct_state_access && !old_legacy && (!unit.supports_legacy() || !legacy))
+               if(ARB_direct_state_access)
                        glBindTextureUnit(i, id);
                else
                {
                        unit.bind();
-                       if(unit.supports_legacy())
-                       {
-                               if(old && old->target!=target && old_legacy)
-                                       glDisable(old->target);
-                               if((!old || old->target!=target) && legacy)
-                                       glEnable(target);
-                       }
                        glBindTexture(target, id);
                }
 
@@ -373,26 +353,18 @@ void Texture::unbind_from(unsigned i)
 {
        TexUnit &unit = TexUnit::get_unit(i);
        const Texture *cur = unit.get_texture();
-       bool legacy = unit.get_texture_legacy();
        if(unit.set_texture(0))
        {
-               if(ARB_direct_state_access && !legacy)
+               if(ARB_direct_state_access)
                        glBindTextureUnit(i, 0);
                else
                {
                        unit.bind();
                        glBindTexture(cur->target, 0);
-                       if(unit.supports_legacy() && legacy)
-                               glDisable(cur->target);
                }
        }
 }
 
-bool Texture::is_legacy_target(GLenum target)
-{
-       return target<GL_TEXTURE_1D_ARRAY;
-}
-
 
 Texture::Loader::Loader(Texture &t):
        DataFile::CollectionObjectLoader<Texture>(t, 0)