X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fshaderprogram.h;h=44b097356b9c5dd45d166ee8071f95388ea7a480;hp=9cedab6de0450abdc85998a5f86fb0ebeae1578b;hb=63b52d964e75f9224645c6fbb4ba4387ada506f8;hpb=433bde2ed090928b264203c9f422a5b220857120 diff --git a/src/shaderprogram.h b/src/shaderprogram.h index 9cedab6..44b0973 100644 --- a/src/shaderprogram.h +++ b/src/shaderprogram.h @@ -13,22 +13,13 @@ namespace IPDF class ShaderProgram { public: - ShaderProgram() : m_program(0) {} + ShaderProgram() : m_program(0), m_valid(false) {}; ~ShaderProgram(); - - inline bool AttachGeometryProgram(const char * geometry_file) {return AttachShader(geometry_file, GL_GEOMETRY_SHADER);} - inline bool AttachVertexProgram(const char * vertex_file) {return AttachShader(vertex_file, GL_VERTEX_SHADER);} - inline bool AttachFragmentProgram(const char * fragment_file) {return AttachShader(fragment_file, GL_FRAGMENT_SHADER);} - - /** Read shaders from files and attach them - * @returns false if any of the shaders cannot be attached - */ - inline bool AttachShaderPrograms(const char * geometry_file, const char * vertex_file, const char * fragment_file) - { - return AttachGeometryProgram(geometry_file) && AttachVertexProgram(vertex_file) && AttachFragmentProgram(fragment_file); - } - bool Link(); // currently always returns true? + bool InitialiseShaders(const char * vert_glsl_file, const char * frag_glsl_file, const char * geom_glsl_file = ""); const void Use() const; + + bool Valid() const {return m_valid;} + // Unfortunately, we don't require GL 4.3/ARB_explicit_uniform_location // which would make this obsolete. One uday Mesa will support it. // NOTE: We could actually get away with this by only using UBOs, as @@ -37,10 +28,9 @@ namespace IPDF const GLint GetUniformLocation(const char *uniform_name) const; private: - void LazyCreateProgram(); - /** Read shader source from src_file and attach it as type **/ - bool AttachShader(const char * src_file, GLenum type); char * GetShaderSource(const char * src_file) const; + bool AttachShader(const char * src_file, GLenum type); + GLuint m_program; struct Shader { @@ -48,6 +38,7 @@ namespace IPDF GLuint obj; }; std::vector m_shaders; + bool m_valid; }; }