1 #ifndef _SHADERPROGRAM_H
2 #define _SHADERPROGRAM_H
11 * The "Shader" class represents a GLSL program made from shaders.
16 ShaderProgram() : m_program(0) {}
19 inline bool AttachGeometryProgram(const char * geometry_file) {return AttachShader(geometry_file, GL_GEOMETRY_SHADER);}
20 inline bool AttachVertexProgram(const char * vertex_file) {return AttachShader(vertex_file, GL_VERTEX_SHADER);}
21 inline bool AttachFragmentProgram(const char * fragment_file) {return AttachShader(fragment_file, GL_FRAGMENT_SHADER);}
23 /** Read shaders from files and attach them
24 * @returns false if any of the shaders cannot be attached
26 inline bool AttachShaderPrograms(const char * geometry_file, const char * vertex_file, const char * fragment_file)
28 return AttachGeometryProgram(geometry_file) && AttachVertexProgram(vertex_file) && AttachFragmentProgram(fragment_file);
30 bool Link(); // currently always returns true?
31 const void Use() const;
32 // Unfortunately, we don't require GL 4.3/ARB_explicit_uniform_location
33 // which would make this obsolete. One uday Mesa will support it.
34 // NOTE: We could actually get away with this by only using UBOs, as
35 // Mesa supports ARB_shading_language_420pack, but that'd be a bit more
36 // work right with the way some of our uniforms are laid out at the moment.
37 const GLint GetUniformLocation(const char *uniform_name) const;
40 void LazyCreateProgram();
41 /** Read shader source from src_file and attach it as type **/
42 bool AttachShader(const char * src_file, GLenum type);
43 char * GetShaderSource(const char * src_file) const;
50 std::vector<Shader> m_shaders;
55 #endif // _SHADERPROGRAM_H