aboutsummaryrefslogtreecommitdiff
path: root/src/lua/graphics/luaopen_JSL.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua/graphics/luaopen_JSL.cpp')
-rw-r--r--src/lua/graphics/luaopen_JSL.cpp35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/lua/graphics/luaopen_JSL.cpp b/src/lua/graphics/luaopen_JSL.cpp
index 774f2b6..e644c35 100644
--- a/src/lua/graphics/luaopen_JSL.cpp
+++ b/src/lua/graphics/luaopen_JSL.cpp
@@ -1,23 +1,20 @@
#include "lua/luax.h"
#include "lua/luaopen_types.h"
-#include "Image.h"
-#include "JSL.h"
-#include "Canvas.h"
-#include "Color.h"
+#include "libjin/jin.h"
namespace jin
{
namespace lua
{
- using namespace lua::graphics;
+ using namespace jin::graphics;
- static inline JSLProgram* checkJSLProgram(lua_State* L)
+ typedef Texture Image;
+
+ static inline Ref<JSLProgram>& checkJSLProgram(lua_State* L)
{
Proxy* proxy = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_SHADER);
- if(proxy != nullptr)
- return (JSLProgram*)proxy->object;
- return nullptr;
+ return proxy->getRef<JSLProgram>();
}
static enum VARIABLE_TYPE
@@ -51,7 +48,7 @@ namespace lua
*/
static int l_send(lua_State* L)
{
- JSLProgram* jsl = checkJSLProgram(L);
+ Ref<JSLProgram>& ref = checkJSLProgram(L);
// number Image Texel
const char* typestr = luax_checkstring(L, 2);
// variable name
@@ -64,28 +61,28 @@ namespace lua
case NUMBER:
{
float number = luax_checknumber(L, 4);
- jsl->sendFloat(variable, number);
+ (*ref).sendFloat(variable, number);
break;
}
case IMAGE:
{
Proxy* proxy = (Proxy*)luax_checktype(L, 4, JIN_GRAPHICS_IMAGE);
- Image* tex = (Image*)proxy->object;
- jsl->sendImage(variable, tex);
+ Ref<Image>& tex = proxy->getRef<Image>();
+ (*ref).sendTexture(variable, &(*tex));
break;
}
case CANVAS:
{
Proxy* proxy = (Proxy*)luax_checktype(L, 4, JIN_GRAPHICS_CANVAS);
- Canvas* canvas = (Canvas*)proxy->object;
- jsl->sendCanvas(variable, canvas);
+ Ref<Canvas>& canvas = proxy->getRef<Canvas>();
+ (*ref).sendCanvas(variable, &(*canvas));
break;
}
case VEC2:
{
float x = luax_checknumber(L, 4);
float y = luax_checknumber(L, 5);
- jsl->sendVec2(variable, x, y);
+ (*ref).sendVec2(variable, x, y);
break;
}
case VEC3:
@@ -93,7 +90,7 @@ namespace lua
float x = luax_checknumber(L, 4);
float y = luax_checknumber(L, 5);
float z = luax_checknumber(L, 6);
- jsl->sendVec3(variable, x, y, z);
+ (*ref).sendVec3(variable, x, y, z);
break;
}
case VEC4:
@@ -102,7 +99,7 @@ namespace lua
float y = luax_checknumber(L, 5);
float z = luax_checknumber(L, 6);
float w = luax_checknumber(L, 7);
- jsl->sendVec4(variable, x, y, z, w);
+ (*ref).sendVec4(variable, x, y, z, w);
break;
}
case COLOR:
@@ -112,7 +109,7 @@ namespace lua
col.rgba.g = luax_checkinteger(L, 5);
col.rgba.b = luax_checkinteger(L, 6);
col.rgba.a = luax_checkinteger(L, 7);
- jsl->sendColor(variable, &col);
+ (*ref).sendColor(variable, &col);
break;
}
default: