forked from dgcor/DGEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShaderManager.h
More file actions
executable file
·40 lines (32 loc) · 1.11 KB
/
Copy pathShaderManager.h
File metadata and controls
executable file
·40 lines (32 loc) · 1.11 KB
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
#pragma once
#include <memory>
#include <SFML/Graphics/Shader.hpp>
#include <string>
#include <unordered_map>
struct GameShaders
{
sf::Shader* Game{ nullptr };
sf::Shader* Level{ nullptr };
sf::Shader* Sprite{ nullptr };
bool hasGameShader() const noexcept { return Game != nullptr; }
bool hasLevelShader() const noexcept { return Level != nullptr; }
bool hasSpriteShader() const noexcept { return Sprite != nullptr; }
};
class ShaderManager
{
private:
static const std::string gameText;
static const std::string levelText;
static const std::string spriteText;
std::unordered_map<std::string, std::shared_ptr<sf::Shader>> shaders;
public:
void add(const std::string& id, const std::string& fragmentShaderText);
void add(const std::string& id, const std::string& fragmentShaderText,
const std::string& vertexShaderText);
void add(const std::string& id, const std::string& fragmentShaderText,
const std::string& vertexShaderText, const std::string& geometryShaderText);
sf::Shader* get(const std::string& id) const;
bool has(const std::string& id) const;
void init();
void init(GameShaders& gameShaders) const;
};