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");
21 add_keyword<GL::Texture2D>("texture");
23 add_creator(&Resources::create_font);
24 add_creator(&Resources::create_texture);
27 void Resources::set_path(const FS::Path &p)
32 const GL::Font &Resources::get_default_font() const
35 throw InvalidState("No default font");
40 GL::Font *Resources::create_font(const string &name)
42 RefPtr<GL::Font> fnt=new GL::Font;
43 DataFile::load(*fnt, (path/name).str(), *this);
45 default_font=fnt.get();
49 GL::Texture2D *Resources::create_texture(const string &name)
51 RefPtr<GL::Texture2D> tex=new GL::Texture2D;
52 tex->load_image((path/name).str());
53 tex->set_min_filter(GL::LINEAR);
58 Resources::Loader::Loader(Resources &r):
59 Collection::Loader(r),
62 add("default_font", &Loader::default_font);
63 add("font", &Loader::font);
64 add("style", &Loader::style);
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();
82 void Resources::Loader::style(const string &name)
84 RefPtr<Style> stl=new Style(res);
86 res.add(name, stl.get());