1 #include <msp/core/except.h>
9 Resources::Resources():
13 add_keyword<GL::Font>("font");
14 add_keyword<Graphic>("graphic");
15 add_keyword<Style>("style");
17 add_creator(&Resources::create_font);
18 add_creator(&Resources::create_texture);
21 void Resources::set_path(const Path &p)
26 const GL::Font &Resources::get_default_font() const
29 throw InvalidState("No default font");
34 GL::Font *Resources::create_font(const string &name)
36 RefPtr<GL::Font> fnt=new GL::Font;
37 DataFile::load<GL::Font, Resources &>(*fnt, (path/(name+".font")).str(), *this);
39 default_font=fnt.get();
43 GL::Texture2D *Resources::create_texture(const string &name)
45 RefPtr<GL::Texture2D> tex=new GL::Texture2D;
46 tex->load_image((path/(name+".png")).str());
47 tex->set_min_filter(GL::LINEAR);
52 Resources::Loader::Loader(Resources &r):
53 Collection::Loader(r),
56 add("default_font", &Loader::default_font);
57 add("font", &Loader::font);
60 void Resources::Loader::default_font(const string &name)
62 res.default_font=res.get<GL::Font>(name);
65 void Resources::Loader::font(const string &name)
67 RefPtr<GL::Font> fnt=new GL::Font;
69 res.add(name, fnt.get());
71 res.default_font=fnt.get();