diff options
author | chai <chaifix@163.com> | 2018-08-14 14:56:47 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-08-14 14:56:47 +0800 |
commit | 5c9af043503f92852a1a765b6ecfbc1aea24d2e9 (patch) | |
tree | eb371092c4137a672e7bfc13dc56ee777623ebfe /src/lua/graphics/JSL.h | |
parent | 5162f84be0a4deb447c6ba1226722b049335d525 (diff) |
*update
Diffstat (limited to 'src/lua/graphics/JSL.h')
-rw-r--r-- | src/lua/graphics/JSL.h | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/src/lua/graphics/JSL.h b/src/lua/graphics/JSL.h new file mode 100644 index 0000000..828fac0 --- /dev/null +++ b/src/lua/graphics/JSL.h @@ -0,0 +1,90 @@ +#ifndef __JIN_LUA_GRAPHICS_JSL_H +#define __JIN_LUA_GRAPHICS_JSL_H +#include "libjin/jin.h" +#include "../luaopen_types.h" +#include "Image.h" +#include "Color.h" +#include "Canvas.h" + +namespace jin +{ +namespace lua +{ +namespace graphics +{ + + class JSLProgram : public Object + { + public: + static JSLProgram* createJSLProgram(const char* program); + + inline void use() + { + currentJSLProgram = this; + jslprogram->use(); + } + + static inline void unuse() + { + currentJSLProgram = nullptr; + jin::graphics::JSLProgram::unuse(); + } + + void sendFloat(const char* name, float number) + { + jslprogram->sendFloat(name, number); + } + + void sendImage(const char* name, const Image* image) + { + jslprogram->sendTexture(name, image->getRawImage()); + } + + void sendVec2(const char* name, float x, float y) + { + jslprogram->sendVec2(name, x, y); + } + + void sendVec3(const char* name, float x, float y, float z) + { + jslprogram->sendVec3(name, x, y, z); + } + + void sendVec4(const char* name, float x, float y, float z, float w) + { + jslprogram->sendVec4(name, x, y, z, w); + } + + void sendCanvas(const char* name, const Canvas* canvas) + { + jslprogram->sendCanvas(name, canvas->getRawCanvas()); + } + + void sendColor(const char* name, const lua::graphics::color* col) + { + jslprogram->sendColor(name, col); + } + + static inline JSLProgram* getCurrentJSL() + { + return currentJSLProgram; + } + + private: + + static JSLProgram* currentJSLProgram; + + ~JSLProgram() + { + delete jslprogram; + } + + jin::graphics::JSLProgram * jslprogram; + + }; + +} // graphics +} // lua +} // jin + +#endif
\ No newline at end of file |