diff options
| author | Alexander <alex@cogarr.net> | 2019-10-27 17:25:16 -0400 |
|---|---|---|
| committer | Alexander <alex@cogarr.net> | 2019-10-27 17:25:16 -0400 |
| commit | 0d2de2ba9c616862d7881f089382db772d034f89 (patch) | |
| tree | 5fc58b63c593e2ac17f3353b50318c299f643390 /src/client/lua_api/video | |
| parent | c9db55cdc2f69c3dc7aefabe0cc828a64e377024 (diff) | |
| download | brokengine-0d2de2ba9c616862d7881f089382db772d034f89.tar.gz brokengine-0d2de2ba9c616862d7881f089382db772d034f89.tar.bz2 brokengine-0d2de2ba9c616862d7881f089382db772d034f89.zip | |
Various updates
Diffstat (limited to 'src/client/lua_api/video')
| -rw-r--r-- | src/client/lua_api/video/draw.cpp | 29 | ||||
| -rw-r--r-- | src/client/lua_api/video/draw.hpp | 8 | ||||
| -rw-r--r-- | src/client/lua_api/video/smaterial.cpp | 14 |
3 files changed, 51 insertions, 0 deletions
diff --git a/src/client/lua_api/video/draw.cpp b/src/client/lua_api/video/draw.cpp new file mode 100644 index 0000000..1f38f34 --- /dev/null +++ b/src/client/lua_api/video/draw.cpp @@ -0,0 +1,29 @@ + +#include <irrlicht.h> +#include <shared/lua_api/common.hpp> +#include "draw.hpp" + +using namespace irr; +using namespace video; +using namespace core; + +extern IrrlichtDevice* device; +extern IVideoDriver* driver; +//drawline2d {startx,starty},{endx,endy},{r,g,b,a} +int drawline2d(lua_State *L){ + long r,g,b,a; + popvector4i(L, &r, &g, &b, &a); + long endx, endy; + popvector2i(L, &endx, &endy); + long startx, starty; + popvector2i(L, &startx, &starty); + driver->draw2DLine(position2d<s32>(startx, starty), position2d<s32>(endx,endy), SColor(r,g,b,a)); + return 0; +} + +void draw_register(lua_State *L){ + lua_getglobal(L,"video");//{video} + lua_pushcfunction(L,drawline2d);//{video},drawline2d() + lua_setfield(L,-2,"drawline2d");//{video} + lua_pop(L,1);// +} diff --git a/src/client/lua_api/video/draw.hpp b/src/client/lua_api/video/draw.hpp new file mode 100644 index 0000000..eb5a9a7 --- /dev/null +++ b/src/client/lua_api/video/draw.hpp @@ -0,0 +1,8 @@ + +extern "C" { + #include <lua.h> + #include <lauxlib.h> + #include <lualib.h> +} + +void draw_register(lua_State* L); diff --git a/src/client/lua_api/video/smaterial.cpp b/src/client/lua_api/video/smaterial.cpp index 2ef7053..510748c 100644 --- a/src/client/lua_api/video/smaterial.cpp +++ b/src/client/lua_api/video/smaterial.cpp @@ -38,8 +38,22 @@ int setTexture(lua_State* L){ return 0; } +//{Material},flag,state +int setFlag(lua_State* L){ + int b = lua_toboolean(L,-1);//{material},flag,state + lua_pop(L,1);//{material},flag + int flag = lua_tonumber(L,-1);//{material},flag + lua_pop(L,1);//{material} + lua_getfield(L,-1,"smaterial");//{material},ud_material + SMaterial* mat = (SMaterial*)lua_touserdata(L,-1); + lua_pop(L,2); + mat->setFlag((E_MATERIAL_FLAG)flag,b == 1 ? true : false); + return 0; +} + static const luaL_reg smaterial_m[] = { {"setTexture", setTexture}, + {"setFlag", setFlag}, {0,0}, }; |
