]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texture.cpp
Better handling of unloaded textures
[libs/gl.git] / source / texture.cpp
index 0fa65eadaed0f7b31508c6e9e4fa55a2d6ba4cfe..cf08ac6371ceeacad9f362a49b3970d887e3398f 100644 (file)
@@ -181,6 +181,17 @@ void Texture::set_compare_func(Predicate f)
 
 void Texture::bind_to(unsigned i) const
 {
+       if(!id)
+       {
+               if(manager)
+                       manager->resource_used(*this);
+               if(!id)
+               {
+                       unbind_from(i);
+                       return;
+               }
+       }
+
        TexUnit &unit = TexUnit::get_unit(i);
        const Texture *cur = unit.get_texture();
        if(unit.set_texture(this))