blob: a7f46520aae2db79299470fdabc205f0bef06fb9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
extern "C" {
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
}
#include <irrlicht.h>
#include "itexture.hpp"
#include "iimage.hpp"
#include "../../../shared/lua_api/common.h"
using namespace irr;
using namespace video;
extern IrrlichtDevice* device;
extern IVideoDriver* driver;
//newtexture(string name,IImage* image)
int newitexture(lua_State* L){
IImage* im = (IImage*) lua_touserdata(L,-1);
lua_pop(L,1);
const char* name = lua_tostring(L,-1);
lua_pop(L,1);
ITexture* tex = driver->addTexture(name,im);
if(!tex){
lua_pushstring(L,"Failed to create texture!");
lua_error(L);
}
lua_pushlightuserdata(L,tex);
return 1;
}
void itexture_register(lua_State* L){
lua_getglobal(L,"video");
lua_pushcfunction(L,newitexture);
lua_setfield(L,-2,"newtexture");
}
|