aboutsummaryrefslogtreecommitdiff
path: root/src/client/lua_api/video/smaterial.cpp
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2018-03-27 22:42:57 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2018-03-27 22:42:57 -0400
commit6cf098e3450ba99c238cf0499c6cecaa246f4d50 (patch)
tree175b84e32a3cf24f3fb7356825827f6611bab1ed /src/client/lua_api/video/smaterial.cpp
parent2831e232b886c5e3b0791ea5192f9e5194e6abf3 (diff)
downloadbrokengine-6cf098e3450ba99c238cf0499c6cecaa246f4d50.tar.gz
brokengine-6cf098e3450ba99c238cf0499c6cecaa246f4d50.tar.bz2
brokengine-6cf098e3450ba99c238cf0499c6cecaa246f4d50.zip
Fixed the procedural textures
Procedural textures are now completely working.
Diffstat (limited to 'src/client/lua_api/video/smaterial.cpp')
-rw-r--r--src/client/lua_api/video/smaterial.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/client/lua_api/video/smaterial.cpp b/src/client/lua_api/video/smaterial.cpp
index e5b9eff..c72d4ca 100644
--- a/src/client/lua_api/video/smaterial.cpp
+++ b/src/client/lua_api/video/smaterial.cpp
@@ -10,18 +10,48 @@ extern "C" {
using namespace irr::video;
/*This probably needs a _gc metamethod*/
+//newsmaterial()
int newsmaterial(lua_State* L){
+
SMaterial* mat = new SMaterial();
- lua_pushlightuserdata(L,mat);
+ lua_pushlightuserdata(L,mat);//ud_smaterial
+
+ luaL_getmetatable(L,"smaterial");//ud_smaterial,{m_smaterial}
+ lua_setmetatable(L,-2);//ud_smaterial
+ return 1;
+}
+
+//setMaterial(self,int_num,{ITexture texture})
+int setTexture(lua_State* L){
+ ITexture* tex = (ITexture*)lua_touserdata(L,-1);
+ lua_pop(L,1);
+ double num = lua_tonumber(L,-1);
+ lua_pop(L,1);
+ SMaterial* self = (SMaterial*)lua_touserdata(L,-1);
+ lua_pop(L,1);
return 0;
}
+static const luaL_reg smaterial_m[] = {
+ {"setTexture", setTexture},
+ {0,0},
+};
+
#define set_const(l,x) lua_pushstring(l,#x);lua_pushinteger(l,x);lua_settable(l,-3);
void smaterial_register(lua_State* L){
//Add globals dealing with material flags
+ luaL_newmetatable(L,"smaterial");//{m_smaterial}
+
+ lua_newtable(L);//{m_smaterial},{}
+ luaL_register(L,NULL,smaterial_m);//{m_smaterial},{smaterial}
+
+ lua_setfield(L,-2,"__index");//{m_smaterial}
+
+ lua_pop(L,1);//
+
lua_getglobal(L,"video");//{}
set_const(L,EMF_WIREFRAME);
@@ -46,6 +76,8 @@ void smaterial_register(lua_State* L){
set_const(L,EMF_POLYGON_OFFSET);
lua_pushcfunction(L,newsmaterial);//{},newsmaterial
- lua_setfield(L,-2,"newsmaterial");
+ lua_setfield(L,-2,"newsmaterial");//{}
+
+ lua_pop(L,1);//
}