bloboland

view src/shaders.h @ 1:cfe68befb7cc

some progress
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 15 Dec 2012 23:43:03 +0200
parents
children
line source
1 #ifndef SDR_H_
2 #define SDR_H_
4 #include <vector>
5 #include "vmath/vmath.h"
7 class Shader {
8 private:
9 bool compiled;
11 public:
12 unsigned int sdr;
14 Shader(unsigned int type);
15 ~Shader();
17 void set_source(const char *src);
19 bool compile();
20 bool is_compiled() const;
22 bool load(const char *fname);
23 };
26 // public shader manager interface
27 Shader *get_shader(const char *fname, unsigned int type);
30 class SdrProg {
31 private:
32 // SdrProg does not own the shader objects
33 std::vector<Shader*> shaders;
34 bool linked;
36 public:
37 unsigned int prog;
39 SdrProg();
40 ~SdrProg();
42 void add_shader(Shader *sdr);
43 bool link();
45 bool load(const char *vsfname, const char *psfname);
47 int get_uniform_location(const char *name);
48 int get_attribute_location(const char *name);
50 void set_uniform(const char *name, int val);
51 void set_uniform(const char *name, float val);
52 void set_uniform(const char *name, const Vector2 &v);
53 void set_uniform(const char *name, const Vector3 &v);
54 void set_uniform(const char *name, const Vector4 &v);
55 void set_uniform(const char *name, const Matrix4x4 &mat);
57 void set_uniform(int loc, int val);
58 void set_uniform(int loc, float val);
59 void set_uniform(int loc, const Vector2 &v);
60 void set_uniform(int loc, const Vector3 &v);
61 void set_uniform(int loc, const Vector4 &v);
62 void set_uniform(int loc, const Matrix4x4 &mat);
63 };
65 bool bind_program(const SdrProg *prog);
67 #endif /* SDR_H_ */