]> git.tdb.fi Git - libs/gl.git/blob - source/shader.h
Make animation curve creation more generic
[libs/gl.git] / source / shader.h
1 #ifndef MSP_GL_SHADER_H_
2 #define MSP_GL_SHADER_H_
3
4 #include <string>
5 #include "gl.h"
6
7 namespace Msp {
8 namespace GL {
9
10 /**
11 A single shader stage.  Shaders must be attached to a Program to be used.
12
13 This class can't be instantiated directly.  Use one of the VertexShader and
14 FragmentShader classes to create Shaders.
15 */
16 class Shader
17 {
18 private:
19         unsigned id;
20         bool compiled;
21
22 protected:
23         Shader(GLenum t);
24         Shader(GLenum t, const std::string &);
25 private:
26         void init(GLenum);
27 public:
28         virtual ~Shader();
29
30         void source(unsigned count, const char **str, const int *len);
31         void source(const std::string &str);
32         void source(const char *str, int len);
33         void compile();
34         unsigned get_id() const { return id; }
35         bool is_compiled() const { return compiled; }
36         std::string get_info_log() const;
37 };
38
39
40 class VertexShader: public Shader
41 {
42 public:
43         VertexShader();
44         VertexShader(const std::string &);
45 };
46
47
48 class FragmentShader: public Shader
49 {
50 public:
51         FragmentShader();
52         FragmentShader(const std::string &);
53 };
54
55
56 class GeometryShader: public Shader
57 {
58 public:
59         GeometryShader();
60         GeometryShader(const std::string &);
61 };
62
63 } // namespace GL
64 } // namespace Msp
65
66 #endif