default_font(0)
{
add_type<Graphic>().keyword("graphic");
- add_type<GL::Texture2D>().keyword("texture");
+ add_type<GL::Texture2D>().keyword("texture").creator(&Resources::create_texture);
add_type<GL::Font>().keyword("font");
add_type<Style>().keyword("style");
}
return *default_font;
}
+GL::Texture2D *Resources::create_texture(const string &name)
+{
+ string ext = FS::extpart(name);
+ if(ext==".png" || ext==".jpg")
+ {
+ IO::Seekable *io = open_from_sources(name);
+ Graphics::Image image;
+ image.load_io(*io);
+ GL::Texture2D *tex = new GL::Texture2D;
+ tex->set_min_filter(GL::LINEAR);
+ tex->image(image);
+ return tex;
+ }
+ else
+ return 0;
+}
+
Resources::Loader::Loader(Resources &r):
Collection::Loader(r),