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<Graphic>("graphic");
22 add_creator(&Resources::create_font);
23 add_creator(&Resources::create_texture);
26 void Resources::set_path(const Path &p)
31 const GL::Font &Resources::get_default_font() const
34 throw InvalidState("No default font");
39 GL::Font *Resources::create_font(const string &name)
41 RefPtr<GL::Font> fnt=new GL::Font;
42 DataFile::load<GL::Font, Resources &>(*fnt, (path/name).str(), *this);
44 default_font=fnt.get();
48 GL::Texture2D *Resources::create_texture(const string &name)
50 RefPtr<GL::Texture2D> tex=new GL::Texture2D;
51 tex->load_image((path/name).str());
52 tex->set_min_filter(GL::LINEAR);
57 Resources::Loader::Loader(Resources &r):
58 Collection::Loader(r),
61 add("default_font", &Loader::default_font);
62 add("font", &Loader::font);
63 add("style", &Loader::style);
66 void Resources::Loader::default_font(const string &name)
68 res.default_font=res.get<GL::Font>(name);
71 void Resources::Loader::font(const string &name)
73 RefPtr<GL::Font> fnt=new GL::Font;
75 res.add(name, fnt.get());
77 res.default_font=fnt.get();
81 void Resources::Loader::style(const string &name)
83 RefPtr<Style> stl=new Style(res);
85 res.add(name, stl.get());