1 #include <msp/fs/utils.h>
11 #include "resources.h"
12 #include "technique.h"
13 #include "texture2d.h"
14 #include "texturecube.h"
21 Resources::Resources():
22 default_tex_filter(LINEAR_MIPMAP_LINEAR)
24 add_type<Animation>().suffix(".anim").keyword("animation");
25 add_type<Armature>().suffix(".arma").keyword("armature");
26 add_type<Font>().keyword("font");
27 add_type<KeyFrame>().suffix(".kframe").keyword("keyframe");
28 add_type<Material>().suffix(".mat").keyword("material");
29 add_type<Mesh>().keyword("mesh");
30 add_type<Object>().keyword("object");
31 add_type<Pose>().keyword("pose");
32 add_type<Program>().keyword("shader");
33 add_type<Technique>().suffix(".tech").keyword("technique");
34 add_type<Texture2D>().base<Texture>().suffix(".tex2d").suffix(".png").suffix(".jpg").keyword("texture2d").creator(&Resources::create_texture2d);
35 add_type<TextureCube>().base<Texture>().suffix(".texcb").keyword("texture_cube");
38 void Resources::set_default_texture_filter(TextureFilter tf)
40 default_tex_filter = tf;
43 Texture2D *Resources::create_texture2d(const string &name)
45 string ext = FS::extpart(name);
49 if(RefPtr<IO::Seekable> io = open_from_sources(name))
51 Graphics::Image image;
54 RefPtr<GL::Texture2D> tex = new GL::Texture2D;
56 if(default_tex_filter==NEAREST_MIPMAP_NEAREST || default_tex_filter==NEAREST_MIPMAP_LINEAR ||
57 default_tex_filter==LINEAR_MIPMAP_NEAREST || default_tex_filter==LINEAR_MIPMAP_LINEAR)
59 tex->set_generate_mipmap(true);
60 tex->set_mag_filter(LINEAR);
63 tex->set_mag_filter(default_tex_filter);
64 tex->set_min_filter(default_tex_filter);