More debugging, harder realops test
[ipdf/code.git] / src / shaderprogram.h
1 #ifndef _SHADERPROGRAM_H
2 #define _SHADERPROGRAM_H
3
4 #include <vector>
5 #include "gl_core44.h"
6
7
8 namespace IPDF
9 {
10         /**
11          * The "Shader" class represents a GLSL program made from shaders.
12          */
13         class ShaderProgram
14         {
15         public:
16                 ShaderProgram() : m_program(0), m_valid(false) {};
17                 ~ShaderProgram();
18                 bool InitialiseShaders(const char * vert_glsl_file, const char * frag_glsl_file, const char * geom_glsl_file = "");
19                 const void Use() const;
20
21                 bool Valid() const {return m_valid;}
22                 
23                 // Unfortunately, we don't require GL 4.3/ARB_explicit_uniform_location
24                 // which would make this obsolete. One uday Mesa will support it.
25                 // NOTE: We could actually get away with this by only using UBOs, as
26                 // Mesa supports ARB_shading_language_420pack, but that'd be a bit more
27                 // work right with the way some of our uniforms are laid out at the moment.
28                 const GLint GetUniformLocation(const char *uniform_name) const;
29
30         private:
31                 char * GetShaderSource(const char * src_file) const;
32                 bool AttachShader(const char * src_file, GLenum type);
33
34                 GLuint m_program;
35                 struct Shader
36                 {
37                         GLenum type;
38                         GLuint obj;
39                 };
40                 std::vector<Shader> m_shaders;
41                 bool m_valid;
42         };
43
44 }
45
46 #endif // _SHADERPROGRAM_H

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