28832f68a11dfe1a81ac4df9fa62209d8521f7f0
[demo] / src / shader.h
1 #ifndef SHADER_H_
2 #define SHADER_H_
3
4 enum SType {
5         SDR_UNKNOWN,
6         SDR_VERTEX,
7         SDR_FRAGMENT
8 };
9
10 class Shader {
11 protected:
12         virtual bool create(char *buf, unsigned int bsz, const char *fname) = 0;
13
14 public:
15         SType type;
16
17         Shader();
18         virtual ~Shader() = 0;
19
20         virtual void destroy() = 0;
21         virtual bool load(const char *fname, SType type);
22         virtual void attach(unsigned int prog) = 0; // if vulkan -> leave empty
23 };
24
25 class ShaderProgram {
26 protected:
27         Shader *shaders[2];
28
29 public:
30         ShaderProgram();
31         virtual ~ShaderProgram();
32
33         virtual void add_shader(Shader *sdr);
34         virtual bool link() = 0;
35         virtual bool load(const char *vfname, const char *ffname) = 0;
36         virtual void use() = 0;
37
38         /* THIS PART IS GOING TO BE CHANGED: on vulkan we set the uniforms
39            using descriptor sets. The current design is suitable for OpenGL and
40            it has to become more generic to work with both APIs later. */
41 };
42
43 #endif // SHADER_H_