]> git.tdb.fi Git - libs/gl.git/commitdiff
Unmanage texture if loading data directly
authorMikko Rasa <tdb@tdb.fi>
Sat, 17 Apr 2021 22:05:20 +0000 (01:05 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 17 Apr 2021 22:10:56 +0000 (01:10 +0300)
Otherwise the resource manager won't have a load location for the texture
and will throw an exception.

Also generate ID if it hasn't been done yet.

source/core/texture.cpp
source/core/texture2d.cpp

index 3eb48b8b2eb426dafebd1791ab11d4fba09b4c63..354c1b12d5307b53113c0ae7080f2635c3e0f3a9 100644 (file)
@@ -361,6 +361,13 @@ void Texture::Loader::generate_mipmap(bool gm)
 
 void Texture::Loader::image_data(const string &data)
 {
+       if(obj.manager)
+       {
+               obj.set_manager(0);
+               if(!obj.id)
+                       obj.generate_id();
+       }
+
        Graphics::Image img;
        IO::Memory mem(data.data(), data.size());
        img.load_io(mem);
index 0f06790c06056f419f6f50766db8a4eb975793f3..6e7d97202f341cc12e2a76d9e94b92f840c3ff94 100644 (file)
@@ -230,6 +230,12 @@ void Texture2D::Loader::init()
 
 void Texture2D::Loader::raw_data(const string &data)
 {
+       if(obj.manager)
+       {
+               obj.set_manager(0);
+               if(!obj.id)
+                       obj.generate_id();
+       }
        obj.image(0, data.data());
 }