Reworked the way shaders are configured to reduce the amount of times clicks on buttons cause the shared shaders to reset.

This commit is contained in:
Zed A. Shaw 2025-04-14 23:06:08 -04:00
parent 19b9a4affd
commit 84a5f06dac
5 changed files with 24 additions and 25 deletions

View file

@ -7,16 +7,16 @@
#include <memory>
namespace shaders {
using std::shared_ptr, std::make_shared;
using std::shared_ptr, std::make_shared;
static ShaderManager SMGR;
static bool INITIALIZED = false;
static int VERSION = 0;
static ShaderManager SMGR;
static bool INITIALIZED = false;
static int VERSION = 0;
bool load_shader(std::string name, nlohmann::json& settings) {
std::string file_name = settings["file_name"];
auto ptr = std::make_shared<sf::Shader>();
bool good = ptr->loadFromFile(file_name, sf::Shader::Type::Fragment);
bool load_shader(std::string name, nlohmann::json& settings) {
std::string file_name = settings["file_name"];
auto ptr = std::make_shared<sf::Shader>();
bool good = ptr->loadFromFile(file_name, sf::Shader::Type::Fragment);
if(good) SMGR.shaders.try_emplace(name, name, file_name, ptr);
return good;
}