]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/resources.cpp
Use nullptr instead of 0 for pointers
[libs/gltk.git] / source / resources.cpp
index 06fa44cf0c502867a1ecb255bea5de9251cc6314..078b58b71696559b16b12267f0e39c8759852373 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;
@@ -53,9 +45,9 @@ const GL::Font &Resources::get_default_font() const
 GL::Module *Resources::create_module(const string &name)
 {
        if(name!="ui.glsl")
-               return 0;
+               return nullptr;
 
-       GL::Module *mod = 0;
+       GL::Module *mod = nullptr;
        if(GL::get_backend_api()==GL::VULKAN)
                mod = new GL::SpirVModule;
        else
@@ -72,7 +64,7 @@ GL::Module *Resources::create_module(const string &name)
 GL::Program *Resources::create_program(const string &name)
 {
        if(name!="ui.shader")
-               return 0;
+               return nullptr;
 
        return new GL::Program(get<GL::Module>("ui.glsl"));
 }
@@ -88,7 +80,7 @@ GL::Sampler *Resources::create_sampler(const string &name)
                return sampler;
        }
 
-       return 0;
+       return nullptr;
 }
 
 GL::Texture2D *Resources::create_texture(const string &name)
@@ -106,7 +98,7 @@ GL::Texture2D *Resources::create_texture(const string &name)
                        return tex;
                }
 
-       return 0;
+       return nullptr;
 }