This covers many simple use cases and avoids the need of creating a
sub-class to add sources or load data before a Root is created.
namespace Msp {
namespace GLtk {
-Resources::Resources():
- default_font(0)
+Resources::Resources()
{
+ init();
+}
+
+Resources::Resources(const FS::Path &fn)
+{
+ init();
+
+ dir_src = new DataFile::DirectorySource;
+ dir_src->add_directory(FS::dirname(fn));
+ add_source(*dir_src);
+
+ DataFile::load(*this, fn.str());
+}
+
+void Resources::init()
+{
+ default_font = 0;
+ dir_src = 0;
add_type<Graphic>().keyword("graphic");
add_type<GL::Texture2D>().keyword("texture").creator(&Resources::create_texture);
add_type<GL::Font>().keyword("font");
add_type<Style>().keyword("style");
}
+Resources::~Resources()
+{
+ delete dir_src;
+}
+
const GL::Font &Resources::get_default_font() const
{
if(!default_font)
#include <msp/gl/font.h>
#include <msp/gl/texture.h>
#include <msp/datafile/collection.h>
+#include <msp/datafile/directorysource.h>
#include <msp/fs/path.h>
#include "graphic.h"
#include "style.h"
private:
FS::Path path;
GL::Font *default_font;
+ DataFile::DirectorySource *dir_src;
public:
class Loader: public Collection::Loader
public:
Resources();
+ Resources(const FS::Path &);
+private:
+ void init();
+public:
+ ~Resources();
const GL::Font &get_default_font() const;