2 #ifndef SHADERLIBRARY_H_ 3 #define SHADERLIBRARY_H_ 5 #include <unordered_map> 22 void add(
const string &name,
Program* program);
23 void add(
const char* name,
Program* program){add(
string(name), program);}
25 bool loadFromJSONCollection(
string path,
bool silent =
false);
27 bool buildAndAdd(
string name,
const json& program_obj);
28 bool buildAndAdd(
const char*
const name,
const json& program_obj) {
return(buildAndAdd(
string(name), program_obj));}
30 bool buildAndAdd(
string name, istream &vertex, istream &fragment);
31 bool buildAndAdd(
const char*
const name, istream &vertex, istream &fragment) {
return(buildAndAdd(
string(name), vertex, fragment));}
32 bool buildAndAdd(
string name,
const string &vpath,
const string &fpath);
33 bool buildAndAdd(
const char*
const name,
const string &vpath,
const string &fpath) {
return(buildAndAdd(
string(name), vpath, fpath));}
35 void printLibary()
const;
38 void makeActive(
const string &name);
39 void makeActive(
const char* name){makeActive(
string(name));}
43 void fastActivate(
Program* prog);
50 Program* operator[](
const string& name) {
return(getPtr(name));}
51 Program* operator[](
const char* name) {
return(getPtr(
string(name)));}
54 Program* getPtr(
const string &name);
55 Program* getPtr(
const char* name){
return(getPtr(
string(name)));}
57 void dumpBinary(
const string& name);
58 void dumpBinary(
const char* name){dumpBinary(
string(name));}
67 unordered_map<string, Program*> programs;
70 vector<Program> localPrograms;
79 constexpr
const static char* errorvs =
"#version 330 core\n" 80 "layout(location = 0) in vec4 vertPos;\n" 88 " gl_Position = P * V * M * vertPos;\n" 92 constexpr
const static char* errorfs =
"#version 330 core\n" 98 " vec3 col = vec3(1.0,0.0,1.0);\n" 99 " color = vec4(col, 1.0);\n"
Definition: ShaderLibrary.hpp:13