Rayview now uses the shader manager.
This commit is contained in:
parent
edee3ac0c9
commit
766b20f3f8
5 changed files with 14 additions and 11 deletions
11
shaders.cpp
11
shaders.cpp
|
@ -12,7 +12,6 @@ namespace shaders {
|
|||
static ShaderManager SMGR;
|
||||
static bool initialized = false;
|
||||
|
||||
|
||||
bool load_shader(std::string name, nlohmann::json& settings) {
|
||||
std::string file_name = settings["file_name"];
|
||||
auto ptr = std::make_shared<sf::Shader>();
|
||||
|
@ -23,6 +22,7 @@ namespace shaders {
|
|||
|
||||
void init() {
|
||||
if(!initialized) {
|
||||
dbc::check(sf::Shader::isAvailable(), "no shaders?!");
|
||||
initialized = true;
|
||||
Config config("assets/shaders.json");
|
||||
bool good = load_shader("ERROR", config["ERROR"]);
|
||||
|
@ -43,13 +43,16 @@ namespace shaders {
|
|||
}
|
||||
}
|
||||
|
||||
sf::Shader* get(std::string name) {
|
||||
std::shared_ptr<sf::Shader> get_shared(std::string& name) {
|
||||
dbc::check(initialized, "you forgot to shaders::init()");
|
||||
dbc::check(SMGR.shaders.contains(name),
|
||||
fmt::format("shader name '{}' not in assets/shaders.json", name));
|
||||
|
||||
auto& rec = SMGR.shaders.at(name);
|
||||
return rec.ptr.get();
|
||||
return rec.ptr;
|
||||
}
|
||||
|
||||
sf::Shader* get(std::string name) {
|
||||
return get_shared(name).get();
|
||||
}
|
||||
|
||||
void reload() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue