]> git.tdb.fi Git - libs/gl.git/commitdiff
Don't use resource manager for builtin data
authorMikko Rasa <tdb@tdb.fi>
Tue, 2 Nov 2021 11:32:33 +0000 (13:32 +0200)
committerMikko Rasa <tdb@tdb.fi>
Tue, 2 Nov 2021 13:11:17 +0000 (15:11 +0200)
Detecting them by the underscore at the beginning of the name feels a
little dodgy, but it will do for now.

source/resources/resources.cpp

index a0ee5e851e19d62f8e06411478b885f8de84658d..7cbdd2c5069f3bc8f51311bfa52e3183f7457787 100644 (file)
@@ -166,7 +166,7 @@ T *Resources::create_generic(const string &name)
 
 Mesh *Resources::create_mesh(const string &name)
 {
-       if(!resource_manager)
+       if(!resource_manager || name[0]=='_')
                return 0;
 
        if(RefPtr<IO::Seekable> io = open_raw(name))
@@ -182,9 +182,16 @@ Mesh *Resources::create_mesh(const string &name)
 
 Texture *Resources::create_texture(const string &name)
 {
+       bool managed = (resource_manager && name[0]!='_');
+
        string ext = FS::extpart(name);
        if(ext==".tex")
-               return create_generic<Texture, GenericResourceLoader<Texture>>(name);
+       {
+               if(managed)
+                       return create_generic<Texture, GenericResourceLoader<Texture>>(name);
+               else
+                       return create_generic<Texture>(name);
+       }
 
        if(RefPtr<IO::Seekable> io = open_raw(name))
        {
@@ -192,14 +199,16 @@ Texture *Resources::create_texture(const string &name)
 
                // Verify that the image is loadable
                Graphics::Image image;
-               if(!resource_manager)
+               if(!managed)
                        image.load_io(*io);
 
                tex = new Texture2D;
-               tex->set_manager(resource_manager);
 
-               if(resource_manager)
+               if(managed)
+               {
+                       tex->set_manager(resource_manager);
                        resource_manager->set_resource_location(*tex, *this, name);
+               }
                else
                        tex->image(image);