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