]> git.tdb.fi Git - libs/gl.git/commitdiff
Use asynchronous resource loading in desertpillars
authorMikko Rasa <tdb@tdb.fi>
Sun, 7 Nov 2021 08:23:56 +0000 (10:23 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 7 Nov 2021 09:01:58 +0000 (11:01 +0200)
demos/desertpillars/source/desertpillars.cpp
demos/desertpillars/source/desertpillars.h

index 542ade3b0a8164cb668926e8312bfc90121c67e2..53f0a86c72cee3c957b66c0f174a10036b983eab 100644 (file)
@@ -25,6 +25,7 @@ DesertPillars::DesertPillars(int, char **):
        window(display, opts.wnd_opts),
        gl_ctx(window, opts.gl_opts),
        keyboard(window),
+       resources(&res_mgr),
        view(window, gl_ctx),
        camera(resources.get<GL::Camera>("Camera.camera")),
        lighting(resources.get<GL::Lighting>("Desert.lightn")),
@@ -123,6 +124,7 @@ void DesertPillars::tick()
        flare.set_matrix(GL::Matrix::translation(p));
 
        display.tick();
+       res_mgr.tick();
        view.render();
 }
 
@@ -139,13 +141,15 @@ void DesertPillars::key_press(unsigned key)
 }
 
 
-DesertPillars::Resources::Resources()
+DesertPillars::Resources::Resources(GL::ResourceManager *rm)
 {
        FS::Path base_dir = FS::get_sys_data_dir()/"demos"/"desertpillars"/"data";
        source.add_directory(base_dir);
        source.add_directory(base_dir/"textures");
        source.add_directory(base_dir/"exported");
        add_source(source);
+
+       set_resource_manager(rm);
 }
 
 
index 0a3f2f2e336481598920722b76305d156dd5a80d..4e4780991275243ebcc5abdc94e69c833e55c7c2 100644 (file)
@@ -36,9 +36,10 @@ private:
        {
        private:
                Msp::DataFile::DirectorySource source;
+               Msp::GL::ResourceManager res_mgr;
 
        public:
-               Resources();
+               Resources(Msp::GL::ResourceManager *);
        };
 
        class MorphSphere: public Msp::GL::ObjectInstance
@@ -70,6 +71,7 @@ private:
        Msp::Graphics::Window window;
        Msp::Graphics::GLContext gl_ctx;
        Msp::Input::Keyboard keyboard;
+       Msp::GL::ResourceManager res_mgr;
        Resources resources;
 
        Msp::GL::WindowView view;