diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2018-05-28 17:07:04 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2018-05-28 17:07:04 -0400 |
| commit | 06d3e8182d018ca613f177f6ff7a3bbb6494cc79 (patch) | |
| tree | 18289e9d48c03cb3910e5fbe27ffd18c6b81eb53 /src/client/lua_api/load_video.cpp | |
| parent | 5fc253ce728c6e078886e092376c2e0f0320ebd9 (diff) | |
| download | brokengine-06d3e8182d018ca613f177f6ff7a3bbb6494cc79.tar.gz brokengine-06d3e8182d018ca613f177f6ff7a3bbb6494cc79.tar.bz2 brokengine-06d3e8182d018ca613f177f6ff7a3bbb6494cc79.zip | |
Various additions
Various additions, updates, and bugfixes while making mahjong solitare.
Diffstat (limited to 'src/client/lua_api/load_video.cpp')
| -rw-r--r-- | src/client/lua_api/load_video.cpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/client/lua_api/load_video.cpp b/src/client/lua_api/load_video.cpp index 8662aa0..746489a 100644 --- a/src/client/lua_api/load_video.cpp +++ b/src/client/lua_api/load_video.cpp @@ -9,11 +9,72 @@ extern "C" { #include "video/itexture.hpp" #include "video/iimage.hpp" +#include "shared/lua_api/common.h" + +using namespace irr; +using namespace video; +using namespace core; + +extern IrrlichtDevice* device; +extern IVideoDriver* driver; + +//{texture},{x,y} +//{texture},{x,y},{sourcerect},,{color},use_alpha +int draw2dimage(lua_State* L){ + int nargs = lua_gettop(L); + printf("Drawing a 2d image\n"); + if(nargs == 2){ + printf("2-argument version\n"); + long x,y; + popvector2i(L,&x,&y); + lua_getfield(L,-1,"texture"); + ITexture *tex = (ITexture*)lua_touserdata(L,-1); + lua_pop(L,2); + driver->draw2DImage(tex,position2d<s32>(x,y)); + }else if(nargs == 5){ + printf("5-argument version\n"); + int usealpha = lua_toboolean(L,-1); + lua_pop(L,1); + printf("Got usealpha: %d\n",usealpha); + long r,g,b,a; + popvector4i(L,&r,&g,&b,&a); + long ssx,ssy,sex,sey; + poprecti(L,&ssx,&ssy,&sex,&sey); + long x,y; + popvector2i(L,&x,&y); + lua_getfield(L,-1,"texture"); + ITexture *tex = (ITexture*)lua_touserdata(L,-1); + if(tex == NULL){ + lua_pushstring(L,"Tried to draw a NULL texture"); + lua_error(L); + } + lua_pop(L,2); + rect<s32> clipedto; + driver->draw2DImage( + tex, + position2d<s32>(x,y), + rect<s32>(ssx,ssy,sex,sey), + &clipedto, + SColor(a,r,g,b), + usealpha == 1 + ); + }else{ + lua_pushstring(L,"Incorrect number of arguments to video.drawtexture() (expected 2 or 6)"); + lua_error(L); + } + return 0; +} + void load_videofuncs(lua_State* L){ printf("Loading video libraries...\n"); lua_newtable(L);//{} lua_setglobal(L,"video");// + lua_getglobal(L,"video");//{} + lua_pushcfunction(L,draw2dimage);//{},draw2dimage() + lua_setfield(L,-2,"drawtexture");//{} + lua_pop(L,1);// + smaterial_register(L); itexture_register(L); iimage_register(L); |
