X-Git-Url: http://git.mutantstargoat.com?a=blobdiff_plain;f=src%2Fshader.h;h=491eea89c6009c0f5c9308a429a084b6a8636975;hb=86c912d603be75ac8b2fdb2229f1696e9c0c01d9;hp=53f8654453d20bc3624a10b8215e18b71d99afe0;hpb=31bab00bc3b476be9814c1ee06b9a2f0dc77d4e9;p=demo diff --git a/src/shader.h b/src/shader.h index 53f8654..491eea8 100644 --- a/src/shader.h +++ b/src/shader.h @@ -1,16 +1,16 @@ #ifndef SHADER_H_ #define SHADER_H_ +#include + #include #include #include -/* - Shader class -*/ +class Texture; -enum SType { +enum ShaderType { SDR_UNKNOWN, SDR_VERTEX, SDR_FRAGMENT @@ -18,64 +18,35 @@ enum SType { class Shader { protected: - SType type; + ShaderType type; std::string name; virtual bool create(char *buf, unsigned int bsz, const char *fname) = 0; public: - Shader(); virtual ~Shader() = 0; - virtual bool load(const char *fname, SType type); + virtual bool load(const char *fname, ShaderType type); virtual void destroy() = 0; + virtual ShaderType get_type(); }; /* Shader Program */ -struct Uniform { - int location; - std::string name; - int state_idx; -}; - class ShaderProgram { protected: Shader *shaders[2]; - std::vector uniforms; public: ShaderProgram(); virtual ~ShaderProgram(); - virtual void cache_uniforms() = 0; - virtual bool create() = 0; virtual bool link() = 0; - virtual bool use() = 0; + virtual bool use() const = 0; virtual void destroy() = 0; virtual void attach_shader(Shader *shader) = 0; - - /* - THIS PART MIGHT NEED SEVERAL CHANGES: on vulkan we set the uniforms - using descriptor sets. The current design is suitable for OpenGL and - it *might* have to be rewritten to work with both APIs later - */ - - virtual void set_uniformi(int location, int value) = 0; - virtual void set_uniformi(int location, int x, int y) = 0; - virtual void set_uniformi(int location, int x, int y, int z) = 0; - virtual void set_uniformi(int location, int x, int y, int z, int w) = 0; - - virtual void set_uniformf(int location, float value) = 0; - virtual void set_uniformf(int location, float x, float y) = 0; - virtual void set_uniformf(int location, float x, float y, float z) = 0; - virtual void set_uniformf(int location, float x, float y, float z, float w) = 0; - - virtual void set_uniform_matrix(int location, const Mat4 &mat) = 0; }; -ShaderProgram *get_current_program(); - #endif // SHADER_H_