-
-
Save anonymous/fc456bec5acb2412aedb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CShader { | |
public: | |
typedef std::unordered_map<std::string, std::string> DefineMap; | |
typedef std::unordered_map<std::string, GLint> UniformMap; | |
typedef std::vector<std::string> UniformList; | |
typedef std::unordered_map<std::string, GLint> AttributeMap; | |
typedef std::vector<std::string> AttributeList; | |
enum Status { | |
SPrimordial, | |
SError, | |
SUnloaded, | |
SLoaded | |
}; | |
std::string name; | |
int virtualId; | |
Status status; | |
int contextId; | |
GLuint progHandle; | |
GLuint vertHandle; | |
GLuint fragHandle; | |
CFilePath vertPath; | |
CFilePath fragPath; | |
std::string vertSource; | |
std::string fragSource; | |
uint64_t vertLastModified; | |
uint64_t fragLastModified; | |
DefineMap vertDefines; | |
DefineMap fragDefines; | |
UniformMap uniforms; | |
UniformList uniformComplaints; | |
AttributeMap attributes; | |
AttributeList attributeComplaints; | |
CShader(const std::string& name, int virtualId); | |
~CShader(); | |
void declared(); | |
bool createGL(); | |
void destroyGL(bool clearComplaints = true); | |
CShader& setPaths(const CFilePath& commonPath); | |
CShader& setPaths(const CFilePath& vpath, const CFilePath& fpath); | |
CShader& addVertDefine(const std::string& key, const std::string& value); | |
CShader& addVertDefine(const std::string& key); | |
CShader& addFragDefine(const std::string& key, const std::string& value); | |
CShader& addFragDefine(const std::string& key); | |
std::string compileDefineMap(const DefineMap& map); | |
void load(); | |
void reloadFromSource(); | |
bool prepare(); | |
static std::string getShaderLog(GLuint shader); | |
static std::string getProgramLog(GLuint program); | |
void begin(); | |
void end(); | |
GLint getUniformLocation(const std::string& uniform); | |
GLint getAttributeLocation(const std::string& attribute); | |
void setUniformf(const std::string& uniform, float value); | |
void setUniformf(const std::string& uniform, const glm::vec2& value); | |
void setUniformf(const std::string& uniform, const glm::vec3& value); | |
void setUniformf(const std::string& uniform, const glm::vec4& value); | |
void setUniformf(const std::string& uniform, int count, float* values); | |
void setUniformf(const std::string& uniform, int count, const glm::vec2* values); | |
void setUniformf(const std::string& uniform, int count, const glm::vec3* values); | |
void setUniformf(const std::string& uniform, int count, const glm::vec4* values); | |
void setUniformi(const std::string& uniform, int value); | |
void setUniformi(const std::string& uniform, const glm::ivec2& value); | |
void setUniformi(const std::string& uniform, const glm::ivec3& value); | |
void setUniformi(const std::string& uniform, const glm::ivec4& value); | |
void setUniformf(const std::string& uniform, const glm::mat2& value); | |
void setUniformf(const std::string& uniform, const glm::mat3& value); | |
void setUniformf(const std::string& uniform, const glm::mat4& value); | |
bool touchCache(CShaderUniformCache& cache); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment