aboutsummaryrefslogtreecommitdiff
path: root/include/ResourceCache.hpp
blob: 75ebd888774afab31aa70d5797a2d58b088d5a25 (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
#pragma once

#include <SFML/Graphics/Font.hpp>
#include <SFML/Graphics/Texture.hpp>
#include <SFML/Graphics/Shader.hpp>
#include <string>
#include <stdexcept>

namespace dchat
{
    class FailedToLoadResourceException : public std::runtime_error
    {
    public:
        FailedToLoadResourceException(const std::string &errMsg) : std::runtime_error(errMsg) {}
    };
    
    class ResourceCache
    {
    public:
        // Throws FailedToLoadResourceException on failure
        static const sf::Font* getFont(const std::string &filepath);
        
        // Throws FailedToLoadResourceException on failure
        static sf::Texture* getTexture(const std::string &filepath);
        
        static sf::Shader* getShader(const std::string &filepath, sf::Shader::Type shaderType);
    };
}