nuclear@1: #ifndef SDR_H_ nuclear@1: #define SDR_H_ nuclear@1: nuclear@1: #include nuclear@1: #include "vmath/vmath.h" nuclear@1: nuclear@1: class Shader { nuclear@1: private: nuclear@1: bool compiled; nuclear@1: nuclear@1: public: nuclear@1: unsigned int sdr; nuclear@1: nuclear@1: Shader(unsigned int type); nuclear@1: ~Shader(); nuclear@1: nuclear@1: void set_source(const char *src); nuclear@1: nuclear@1: bool compile(); nuclear@1: bool is_compiled() const; nuclear@1: nuclear@1: bool load(const char *fname); nuclear@1: }; nuclear@1: nuclear@1: nuclear@1: // public shader manager interface nuclear@1: Shader *get_shader(const char *fname, unsigned int type); nuclear@1: nuclear@1: nuclear@1: class SdrProg { nuclear@1: private: nuclear@1: // SdrProg does not own the shader objects nuclear@1: std::vector shaders; nuclear@1: bool linked; nuclear@1: nuclear@1: public: nuclear@1: unsigned int prog; nuclear@1: nuclear@1: SdrProg(); nuclear@1: ~SdrProg(); nuclear@1: nuclear@1: void add_shader(Shader *sdr); nuclear@1: bool link(); nuclear@1: nuclear@1: bool load(const char *vsfname, const char *psfname); nuclear@1: nuclear@1: int get_uniform_location(const char *name); nuclear@1: int get_attribute_location(const char *name); nuclear@1: nuclear@1: void set_uniform(const char *name, int val); nuclear@1: void set_uniform(const char *name, float val); nuclear@1: void set_uniform(const char *name, const Vector2 &v); nuclear@1: void set_uniform(const char *name, const Vector3 &v); nuclear@1: void set_uniform(const char *name, const Vector4 &v); nuclear@1: void set_uniform(const char *name, const Matrix4x4 &mat); nuclear@1: nuclear@1: void set_uniform(int loc, int val); nuclear@1: void set_uniform(int loc, float val); nuclear@1: void set_uniform(int loc, const Vector2 &v); nuclear@1: void set_uniform(int loc, const Vector3 &v); nuclear@1: void set_uniform(int loc, const Vector4 &v); nuclear@1: void set_uniform(int loc, const Matrix4x4 &mat); nuclear@1: }; nuclear@1: nuclear@1: bool bind_program(const SdrProg *prog); nuclear@1: nuclear@1: #endif /* SDR_H_ */