]> git.tdb.fi Git - libs/gl.git/blobdiff - source/texture.cpp
Support linear to sRGB conversion when loading materials and textures
[libs/gl.git] / source / texture.cpp
index fe8b7be9a3e4fbb56dda02464bfb0541d8e131ce..d738bb36e9a63c2df69ef97a205e292b59aa5b49 100644 (file)
@@ -2,6 +2,7 @@
 #include <msp/gl/extensions/sgis_generate_mipmap.h>
 #include <msp/strings/format.h>
 #include "error.h"
+#include "resources.h"
 #include "texture.h"
 #include "texunit.h"
 
@@ -209,8 +210,24 @@ void Texture::unbind_from(unsigned i)
 
 
 Texture::Loader::Loader(Texture &t):
-       DataFile::ObjectLoader<Texture>(t)
+       DataFile::CollectionObjectLoader<Texture>(t, 0)
 {
+       init();
+}
+
+Texture::Loader::Loader(Texture &t, Collection &c):
+       DataFile::CollectionObjectLoader<Texture>(t, &c)
+{
+       init();
+}
+
+void Texture::Loader::init()
+{
+       if(Resources *res = dynamic_cast<Resources *>(coll))
+               srgb = res->get_srgb_conversion();
+       else
+               srgb = false;
+
        add("filter", &Loader::filter);
        add("max_anisotropy", &Loader::max_anisotropy);
        add("generate_mipmap", &Loader::generate_mipmap);