diff options
author | chai <chaifix@163.com> | 2018-07-28 10:39:31 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-07-28 10:39:31 +0800 |
commit | 589ee7ee7014a5f8918e1d99c0e04bff4f7a83cb (patch) | |
tree | 8d377c830bcc68afd24b02f97a0811d3d4c50598 /src/libjin/Graphics/JSL.h | |
parent | 654a75401775d74f95f3d98611e333bb5641ee9b (diff) |
*update
Diffstat (limited to 'src/libjin/Graphics/JSL.h')
-rw-r--r-- | src/libjin/Graphics/JSL.h | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/libjin/Graphics/JSL.h b/src/libjin/Graphics/JSL.h new file mode 100644 index 0000000..3872802 --- /dev/null +++ b/src/libjin/Graphics/JSL.h @@ -0,0 +1,74 @@ +#ifndef __JIN_JSL_H +#define __JIN_JSL_H +#include "../modules.h" +#if JIN_MODULES_RENDER + +#include <string> +#include <map> +#include "color.h" +#include "texture.h" +#include "canvas.h" +#include "../3rdparty/GLee/GLee.h" + +namespace jin +{ +namespace graphics +{ + + class JSLProgram + { + + public: + + static JSLProgram* createJSLProgram(const char* program); + + ~JSLProgram(); + + inline void JSLProgram::use() + { + glUseProgram(pid); + currentJSLProgram = this; + } + + static inline void JSLProgram::unuse() + { + glUseProgram(0); + currentJSLProgram = nullptr; + } + + 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); + + static inline JSLProgram* getCurrentJSL() + { + return currentJSLProgram; + } + + private: + + JSLProgram(const char* program); + + static JSLProgram* currentJSLProgram; + + GLuint pid; + + std::map<std::string, GLint> texturePool; + + GLint currentTextureUnit; + GLint getTextureUnit(const std::string& name); + + inline void initialize(const char* program); + inline void destroy(); + + }; + +} +} + +#endif // JIN_MODULES_RENDER +#endif // __JIN_JSL_H
\ No newline at end of file |