From 05ebedc397432f054cdc367d35f86fd610fbfee6 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 6 Sep 2018 09:43:47 +0800 Subject: *update --- src/libjin/Graphics/Shader.h | 54 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/libjin/Graphics/Shader.h (limited to 'src/libjin/Graphics/Shader.h') diff --git a/src/libjin/Graphics/Shader.h b/src/libjin/Graphics/Shader.h new file mode 100644 index 0000000..24c889d --- /dev/null +++ b/src/libjin/Graphics/Shader.h @@ -0,0 +1,54 @@ +#ifndef __JIN_JSL_H +#define __JIN_JSL_H +#include "../modules.h" +#if JIN_MODULES_RENDER + +#include +#include +#include "color.h" +#include "texture.h" +#include "canvas.h" +#include "../3rdparty/GLee/GLee.h" + +namespace jin +{ +namespace graphics +{ + + /* Jin Shader Language Program*/ + class JSLProgram + { + public: + static JSLProgram* createJSLProgram(const char* program); + static inline JSLProgram* getCurrentJSL() { return currentJSLProgram; } + static void unuse(); + + virtual ~JSLProgram(); + + void use(); + void sendFloat(const char* name, float number); + void sendTexture(const char* name, const Texture* image); + void sendVec2(const char* name, float x, float y); + void sendVec3(const char* name, float x, float y, float z); + void sendVec4(const char* name, float x, float y, float z, float w); + void sendCanvas(const char* name, const Canvas* canvas); + void sendColor(const char* name, const color* col); + + protected: + GLint claimTextureUnit(const std::string& name); + JSLProgram(const char* program); + void bindDefaultTex(); + + static JSLProgram* currentJSLProgram; + + GLuint pid; + GLint currentTextureUnit; + std::map textureUnits; + + }; + +} // graphics +} // jin + +#endif // JIN_MODULES_RENDER +#endif // __JIN_JSL_H \ No newline at end of file -- cgit v1.1-26-g67d0