X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fshaderprogram.h;h=44b097356b9c5dd45d166ee8071f95388ea7a480;hp=25318d704047cfd625eff8764c1b45e860fbb22c;hb=da646c739f87bf28c5a7af2bc180b93b3444321b;hpb=a851cf197844a2eb15fd5ee2c350ee296e415dca diff --git a/src/shaderprogram.h b/src/shaderprogram.h index 25318d7..44b0973 100644 --- a/src/shaderprogram.h +++ b/src/shaderprogram.h @@ -7,27 +7,30 @@ namespace IPDF { - /* - * The "Shader" class represents a GLSL program made from shaders. + /** + * The "Shader" class represents a GLSL program made from shaders. */ class ShaderProgram { public: - ShaderProgram() : m_program(0) {} + ShaderProgram() : m_program(0), m_valid(false) {}; ~ShaderProgram(); - bool AttachVertexProgram(const char *src); - bool AttachFragmentProgram(const char *src); - bool Link(); + 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 // Mesa supports ARB_shading_language_420pack, but that'd be a bit more // work right with the way some of our uniforms are laid out at the moment. const GLint GetUniformLocation(const char *uniform_name) const; + private: - void LazyCreateProgram(); - bool AttachShader(const char *src, GLenum type); + char * GetShaderSource(const char * src_file) const; + bool AttachShader(const char * src_file, GLenum type); + GLuint m_program; struct Shader { @@ -35,6 +38,7 @@ namespace IPDF GLuint obj; }; std::vector m_shaders; + bool m_valid; }; }