12 #ifndef GLVIS_SHADER_HPP
13 #define GLVIS_SHADER_HPP
17 #include <unordered_map>
26 program_id = glCreateProgram();
29 std::cerr <<
"Failed to create an OpenGL program object." << std::endl;
33 bool create(std::string vertexShader,
34 std::string fragmentShader,
35 std::unordered_map<int, std::string> inAttributes,
40 int uniform(std::string uniformName)
const
42 auto unifId = uniform_idx.find(uniformName);
43 if (unifId != uniform_idx.end())
45 return unifId->second;
57 void bind()
const { glUseProgram(program_id); }
60 static void GetGLSLVersion();
62 std::string formatShader(
const std::string& inShader, GLenum shaderType);
63 GLuint compileShader(
const std::string& inShader, GLenum shaderType);
64 bool linkShaders(
const std::vector<GLuint>& shaders);
65 void mapShaderUniforms();
67 static int glsl_version;
68 const static bool glsl_is_es;
69 std::unordered_map<int, std::string> attrib_idx;
75 bool is_compiled =
false;
76 std::unordered_map<std::string, GLuint> uniform_idx;
81 #endif // GLVIS_SHADER_HPP
std::unordered_map< std::string, GLuint > getUniformMap() const
GLuint getProgramId() const
bool create(std::string vertexShader, std::string fragmentShader, std::unordered_map< int, std::string > inAttributes, int numOutputs)
int uniform(std::string uniformName) const