mirror of
https://github.com/Kiritow/LuaEngine.git
synced 2024-03-22 13:11:45 +08:00
23 lines
438 B
C++
23 lines
438 B
C++
|
#include "include.h"
|
||
|
|
||
|
int surface_close(lua_State* L)
|
||
|
{
|
||
|
auto surf = lua_checkpointer<SDL_Surface>(L, 1, "LuaEngineSurface");
|
||
|
SDL_FreeSurface(surf);
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
// shared
|
||
|
void put_surface(lua_State* L, SDL_Surface* surf)
|
||
|
{
|
||
|
lua_newpointer(L, surf);
|
||
|
if (luaL_newmetatable(L, "LuaEngineSurface"))
|
||
|
{
|
||
|
lua_setfield_function(L, "__gc", surface_close);
|
||
|
lua_newtable(L);
|
||
|
|
||
|
lua_setfield(L, -2, "__index");
|
||
|
}
|
||
|
lua_setmetatable(L, -2);
|
||
|
}
|