Shaders now are managed by a manger that can do hot reloading and it also will detect a bad shader and use an ERROR shader so you know it's busted visually.

This commit is contained in:
Zed A. Shaw 2025-04-13 17:11:21 -04:00
parent a5b8e411e3
commit 35ced58cc9
14 changed files with 144 additions and 13 deletions

26
shaders.hpp Normal file
View file

@ -0,0 +1,26 @@
#pragma once
#include <cstdint>
#include <vector>
#include <string>
#include <SFML/Graphics.hpp>
#include <unordered_map>
#include <memory>
#include "matrix.hpp"
#include <nlohmann/json.hpp>
namespace shaders {
struct Record {
std::string name;
std::string file_name;
std::shared_ptr<sf::Shader> ptr = nullptr;
};
struct ShaderManager {
std::unordered_map<std::string, Record> shaders;
};
void init();
bool load_shader(std::string& name, nlohmann::json& settings);
sf::Shader* get(std::string name);
void reload();
}