]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texturecube.cpp
Add a datafile statement to use an external image for a texture
[libs/gl.git] / source / texturecube.cpp
index 743eb986247eb95318c98490179b3fdb95683980..3c6f23bd94f05443fd5e872febca8edf19555875 100644 (file)
@@ -1,3 +1,4 @@
+#include <msp/datafile/collection.h>
 #include <msp/gl/extensions/arb_texture_cube_map.h>
 #include <msp/io/memory.h>
 #include <msp/strings/format.h>
@@ -212,11 +213,21 @@ TextureCube::Loader::Loader(TextureCube &t, Collection &c):
 
 void TextureCube::Loader::init()
 {
+       add("external_image", &Loader::external_image);
        add("image_data", &Loader::image_data);
        add("raw_data", &Loader::raw_data);
        add("storage", &Loader::storage);
 }
 
+void TextureCube::Loader::external_image(TextureCubeFace face, const string &fn)
+{
+       Graphics::Image img;
+       RefPtr<IO::Seekable> io = get_collection().open_raw(fn);
+       img.load_io(*io);
+
+       obj.image(face, img, srgb);
+}
+
 void TextureCube::Loader::image_data(TextureCubeFace face, const string &data)
 {
        Graphics::Image img;