Make project relevant to Mechatronics
[ipdf/code.git] / src / shaderprogram.h
index c052566..44b0973 100644 (file)
@@ -7,28 +7,30 @@
 
 namespace IPDF
 {
 
 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:
         */
        class ShaderProgram
        {
        public:
-               ShaderProgram() : m_program(0) {}
+               ShaderProgram() : m_program(0), m_valid(false) {};
                ~ShaderProgram();
                ~ShaderProgram();
-               bool AttachVertexProgram(const char *src);
-               bool AttachFragmentProgram(const char *src);
-               bool AttachGeometryProgram(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;
                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;
                // 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:
        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
                {
                GLuint m_program;
                struct Shader
                {
@@ -36,6 +38,7 @@ namespace IPDF
                        GLuint obj;
                };
                std::vector<Shader> m_shaders;
                        GLuint obj;
                };
                std::vector<Shader> m_shaders;
+               bool m_valid;
        };
 
 }
        };
 
 }

UCC git Repository :: git.ucc.asn.au