3dphotoshoot

view src/shader.h @ 21:4ca4e3c5a754

port to C++ completed, shader programs now use the SdrProg class
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 11 Jun 2015 04:56:33 +0300
parents c14613d27a3a
children d7fe157c402d
line source
1 #ifndef SHADER_H_
2 #define SHADER_H_
4 #include <vector>
6 enum SdrDefaultAttrib {
7 SDR_ATTR_VERTEX,
8 SDR_ATTR_NORMAL,
9 SDR_ATTR_TEXCOORD,
10 SDR_ATTR_COLOR,
11 SDR_ATTR_TANGENT
12 };
15 class SdrProg {
16 private:
17 std::vector<unsigned int> priv_sdr;
18 unsigned int prog;
19 mutable bool valid;
21 public:
22 static const SdrProg *active;
24 SdrProg();
25 ~SdrProg();
27 void create();
28 void destroy();
30 bool attach_shader(unsigned int sdr);
32 bool create(unsigned int vsdr, unsigned int psdr);
33 bool create(const char *vsrc, const char *psrc);
34 bool load(const char *vfname, const char *pfname);
36 bool link() const;
38 int get_uniform(const char *name) const;
39 int get_attrib(const char *name) const;
40 bool bind_attrib(const char *name, int loc) const;
41 void bind_default_attribs() const;
43 bool bind() const;
45 unsigned int get_globj() const { return prog; }
46 };
48 unsigned int get_shader(const char *name, unsigned int type);
50 SdrProg *get_sdrprog(const char *vfile, const char *pfile);
52 #endif /* SHADER_H_ */