aboutsummaryrefslogtreecommitdiff
path: root/src/lua/graphics/JSL.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua/graphics/JSL.h')
-rw-r--r--src/lua/graphics/JSL.h90
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