]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/texture.cpp
Load textures in a type-generic way
[libs/gl.git] / source / core / texture.cpp
index 568479a6d7fd9d187b3a9805af63591283bc9239..54577aacd55e06f389361f0eda96305b42a63057 100644 (file)
@@ -2,6 +2,11 @@
 #include "error.h"
 #include "resourcemanager.h"
 #include "texture.h"
+#include "texture1d.h"
+#include "texture2d.h"
+#include "texture2darray.h"
+#include "texture3d.h"
+#include "texturecube.h"
 
 using namespace std;
 
@@ -61,6 +66,22 @@ void Texture::load_image(const string &fn, unsigned lv)
        image(img, lv);
 }
 
+Texture::GenericLoader::TypeRegistry &Texture::get_texture_registry()
+{
+       static GenericLoader::TypeRegistry registry;
+       static bool initialized = false;
+       if(!initialized)
+       {
+               initialized = true;
+               registry.register_type<Texture1D>("1d");
+               registry.register_type<Texture2D>("2d");
+               registry.register_type<Texture3D>("3d");
+               registry.register_type<Texture2DArray>("2d_array");
+               registry.register_type<TextureCube>("cube");
+       }
+       return registry;
+}
+
 
 Texture::Loader::Loader(Texture &t, Collection *c):
        CollectionObjectLoader<Texture>(t, c),