X-Git-Url: http://git.mutantstargoat.com?p=demo;a=blobdiff_plain;f=src%2Fshader.h;h=abfe36420f5f3b734e4cb13d13c258ed89a06013;hp=28832f68a11dfe1a81ac4df9fa62209d8521f7f0;hb=369d75c73bf926a6dbcf4d740c8664bbb401602a;hpb=0da7a98f74d00bfa6cf0d47fd7cf0f687eeba5f6 diff --git a/src/shader.h b/src/shader.h index 28832f6..abfe364 100644 --- a/src/shader.h +++ b/src/shader.h @@ -1,6 +1,15 @@ #ifndef SHADER_H_ #define SHADER_H_ +#include +#include + +#include + +/* + Shader class +*/ + enum SType { SDR_UNKNOWN, SDR_VERTEX, @@ -17,27 +26,57 @@ public: Shader(); virtual ~Shader() = 0; - virtual void destroy() = 0; virtual bool load(const char *fname, SType type); - virtual void attach(unsigned int prog) = 0; // if vulkan -> leave empty + virtual void destroy() = 0; +}; + +/* 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 void add_shader(Shader *sdr); + virtual void delete_shaders() = 0; + + virtual bool create() = 0; virtual bool link() = 0; - virtual bool load(const char *vfname, const char *ffname) = 0; - virtual void use() = 0; + virtual bool use() = 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 + */ - /* THIS PART IS GOING TO BE CHANGED: on vulkan we set the uniforms - using descriptor sets. The current design is suitable for OpenGL and - it has to become more generic 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_