bloboland

annotate src/shaders.h @ 2:1757973feaed

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