3 This file is part of libmspgltk
4 Copyright © 2007 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #include <msp/core/except.h>
16 Resources::Resources():
20 add_keyword<GL::Font>("font");
21 add_keyword<Graphic>("graphic");
22 add_keyword<Style>("style");
24 add_creator(&Resources::create_font);
25 add_creator(&Resources::create_texture);
28 void Resources::set_path(const Path &p)
33 const GL::Font &Resources::get_default_font() const
36 throw InvalidState("No default font");
41 GL::Font *Resources::create_font(const string &name)
43 RefPtr<GL::Font> fnt=new GL::Font;
44 DataFile::load<GL::Font, Resources &>(*fnt, (path/(name+".font")).str(), *this);
46 default_font=fnt.get();
50 GL::Texture2D *Resources::create_texture(const string &name)
52 RefPtr<GL::Texture2D> tex=new GL::Texture2D;
53 tex->load_image((path/(name+".png")).str());
54 tex->set_min_filter(GL::LINEAR);
59 Resources::Loader::Loader(Resources &r):
60 Collection::Loader(r),
63 add("default_font", &Loader::default_font);
64 add("font", &Loader::font);
67 void Resources::Loader::default_font(const string &name)
69 res.default_font=res.get<GL::Font>(name);
72 void Resources::Loader::font(const string &name)
74 RefPtr<GL::Font> fnt=new GL::Font;
76 res.add(name, fnt.get());
78 res.default_font=fnt.get();