]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/resources.cpp
Simplify constructors with C++11
[libs/gltk.git] / source / resources.cpp
index 06fa44cf0c502867a1ecb255bea5de9251cc6314..3cfd8306275cb5e0ae47268e4dd013749531d310 100644 (file)
@@ -10,13 +10,18 @@ namespace GLtk {
 
 Resources::Resources()
 {
-       init();
+       add_type<Graphic>().keyword("graphic");
+       add_type<GL::Module>().creator([this](const string &n){ return create_module(n); });
+       add_type<GL::Sampler>().creator([this](const string &n){ return create_sampler(n); });
+       add_type<GL::Program>().creator([this](const string &n){ return create_program(n); });
+       add_type<GL::Texture2D>().keyword("texture").creator([this](const string &n){ return create_texture(n); });
+       add_type<GL::Font>().keyword("font");
+       add_type<Style>().keyword("style");
 }
 
-Resources::Resources(const FS::Path &fn)
+Resources::Resources(const FS::Path &fn):
+       Resources()
 {
-       init();
-
        dir_src = new DataFile::DirectorySource;
        dir_src->add_directory(FS::dirname(fn));
        add_source(*dir_src);
@@ -24,19 +29,6 @@ Resources::Resources(const FS::Path &fn)
        DataFile::load(*this, fn.str());
 }
 
-void Resources::init()
-{
-       default_font = 0;
-       dir_src = 0;
-       add_type<Graphic>().keyword("graphic");
-       add_type<GL::Module>().creator([this](const string &n){ return create_module(n); });
-       add_type<GL::Sampler>().creator([this](const string &n){ return create_sampler(n); });
-       add_type<GL::Program>().creator([this](const string &n){ return create_program(n); });
-       add_type<GL::Texture2D>().keyword("texture").creator([this](const string &n){ return create_texture(n); });
-       add_type<GL::Font>().keyword("font");
-       add_type<Style>().keyword("style");
-}
-
 Resources::~Resources()
 {
        delete dir_src;