aboutsummaryrefslogtreecommitdiff
path: root/src/core/hdri_manager.h
blob: fa053308c14dd995fdf39d0d09611df6503ed1a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once

#include "core/log.h"
#include "rendering/texture.h"

#include <string>
#include <unordered_map>
#include <memory>

namespace Donut
{
    class HDRIManager
    {
    public:
        static auto get() -> HDRIManager&
        {
            static HDRIManager instance;
            return instance;
        }

        auto load_hdri(const std::string& path) -> Ref<CubemapTexture>;
        auto get_current_hdri() const -> Ref<CubemapTexture> { return m_current_hdri; }

        auto set_current_hdri(const std::string& path) -> void;
        auto get_available_hdri() const -> const std::vector<std::string>& { return m_available_hdri; }
        auto get_hdri_name(const std::string& path) const -> std::string;
        auto clear_cache() -> void;

    private:
         HDRIManager() = default;
        ~HDRIManager() = default;

        HDRIManager(const HDRIManager&)            = delete;
        HDRIManager& operator=(const HDRIManager&) = delete;

        std::unordered_map<std::string, Ref<CubemapTexture>> m_hdri_cache;

        Ref<CubemapTexture> m_current_hdri;

        std::vector<std::string> m_available_hdri =
        {
            "assets/hdri/HDR_blue_nebulae-1.hdr",
            "assets/hdri/HDR_subdued_blue_nebulae.hdr",
            "assets/hdri/HDR_subdued_multi_nebulae.hdr",
            "assets/hdri/night_sky.hdr"
        };
    };
};