2023-05-14 10:21:03 +00:00
|
|
|
#include <lua5.3/lua.h>
|
|
|
|
#include <lua5.3/lualib.h>
|
|
|
|
#include <lua5.3/lauxlib.h>
|
|
|
|
|
|
|
|
lua_State * engine_lua_state;
|
2023-05-14 18:40:19 +00:00
|
|
|
int engine_luaf_window_init(lua_State *L) {
|
|
|
|
int invar1 = luaL_checkinteger(L,1);
|
|
|
|
int invar2 = luaL_checkinteger(L,2);
|
|
|
|
char * invar3 = (char *)luaL_checkstring(L,3);
|
|
|
|
engine_window_init(invar1,invar2,invar3);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int engine_luaf_window_present(lua_State *L) {
|
|
|
|
engine_window_present();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int engine_luaf_surface_color_set(lua_State *L) {
|
|
|
|
char invar1 = luaL_checkinteger(L,1);
|
|
|
|
char invar2 = luaL_checkinteger(L,2);
|
|
|
|
char invar3 = luaL_checkinteger(L,3);
|
|
|
|
char invar4 = luaL_checkinteger(L,4);
|
|
|
|
engine_surface_color_set(invar1,invar2,invar3,invar4);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int engine_luaf_surface_draw_pixel(lua_State *L) {
|
|
|
|
int invar1 = luaL_checkinteger(L,1);
|
|
|
|
int invar2 = luaL_checkinteger(L,2);
|
|
|
|
engine_surface_draw_pixel(invar1,invar2);
|
|
|
|
return 0;
|
|
|
|
}
|
2023-05-14 10:21:03 +00:00
|
|
|
|
2023-05-14 16:29:55 +00:00
|
|
|
int engine_luaf_time_get(lua_State *L) {
|
2023-05-14 18:40:19 +00:00
|
|
|
long long outvar = engine_time_get();
|
|
|
|
lua_pushinteger(L,outvar);
|
2023-05-14 16:29:55 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2023-05-14 18:40:19 +00:00
|
|
|
|
2023-05-14 16:29:55 +00:00
|
|
|
int engine_luaf_time_sleep(lua_State *L) {
|
2023-05-14 18:40:19 +00:00
|
|
|
long long invar1 = luaL_checkinteger(L,1);
|
|
|
|
engine_time_sleep(invar1);
|
2023-05-14 10:21:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-05-14 19:43:13 +00:00
|
|
|
int engine_luaf_event_get(lua_State *L) {
|
|
|
|
struct ENGINE_EVENT * outvar = engine_event_get();
|
|
|
|
lua_pushlightuserdata(L,outvar);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2023-05-14 16:29:55 +00:00
|
|
|
int engine_luaf_texture_create(lua_State *L) {
|
2023-05-14 18:40:19 +00:00
|
|
|
int invar1 = luaL_checkinteger(L,1);
|
|
|
|
int invar2 = luaL_checkinteger(L,2);
|
|
|
|
struct ENGINE_TEXTURE * outvar = engine_texture_create(invar1,invar2);
|
|
|
|
lua_pushlightuserdata(L,outvar);
|
2023-05-14 10:21:03 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2023-05-14 18:40:19 +00:00
|
|
|
|
|
|
|
int engine_luaf_texture_color_set(lua_State *L) {
|
|
|
|
char invar1 = luaL_checkinteger(L,1);
|
|
|
|
char invar2 = luaL_checkinteger(L,2);
|
|
|
|
char invar3 = luaL_checkinteger(L,3);
|
|
|
|
char invar4 = luaL_checkinteger(L,4);
|
|
|
|
engine_texture_color_set(invar1,invar2,invar3,invar4);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int engine_luaf_texture_draw_pixel(lua_State *L) {
|
|
|
|
struct ENGINE_TEXTURE * invar1 = lua_touserdata(L,1);
|
|
|
|
int invar2 = luaL_checkinteger(L,2);
|
|
|
|
int invar3 = luaL_checkinteger(L,3);
|
|
|
|
engine_texture_draw_pixel(invar1,invar2,invar3);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-05-14 16:29:55 +00:00
|
|
|
int engine_luaf_texture_destroy(lua_State *L) {
|
2023-05-14 18:40:19 +00:00
|
|
|
struct ENGINE_TEXTURE * invar1 = lua_touserdata(L,1);
|
|
|
|
engine_texture_destroy(invar1);
|
2023-05-14 16:29:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2023-05-14 18:40:19 +00:00
|
|
|
|
2023-05-14 16:29:55 +00:00
|
|
|
int engine_luaf_texture_render_2d(lua_State *L) {
|
2023-05-14 18:40:19 +00:00
|
|
|
struct ENGINE_TEXTURE * invar1 = lua_touserdata(L,1);
|
|
|
|
int invar2 = luaL_checkinteger(L,2);
|
|
|
|
int invar3 = luaL_checkinteger(L,3);
|
|
|
|
engine_texture_render_2d(invar1,invar2,invar3);
|
2023-05-14 10:21:03 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2023-05-14 18:40:19 +00:00
|
|
|
|
2023-05-14 16:29:55 +00:00
|
|
|
int engine_luaf_texture_from_file(lua_State *L) {
|
2023-05-14 18:40:19 +00:00
|
|
|
struct ENGINE_TEXTURE * invar1 = lua_touserdata(L,1);
|
|
|
|
char * invar2 = (char *)luaL_checkstring(L,2);
|
|
|
|
engine_texture_from_file(invar1,invar2);
|
2023-05-14 16:29:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2023-05-14 10:21:03 +00:00
|
|
|
|
|
|
|
void engine_luaInit() {
|
|
|
|
engine_lua_state = luaL_newstate();
|
|
|
|
luaL_openlibs(engine_lua_state);
|
2023-05-14 18:40:19 +00:00
|
|
|
|
|
|
|
lua_pushcfunction(engine_lua_state,engine_luaf_window_init);
|
|
|
|
lua_setglobal (engine_lua_state,"engine_window_init");
|
|
|
|
lua_pushcfunction(engine_lua_state,engine_luaf_window_present);
|
|
|
|
lua_setglobal (engine_lua_state,"engine_window_present");
|
|
|
|
lua_pushcfunction(engine_lua_state,engine_luaf_surface_color_set);
|
|
|
|
lua_setglobal (engine_lua_state,"engine_surface_color_set");
|
|
|
|
lua_pushcfunction(engine_lua_state,engine_luaf_surface_draw_pixel);
|
|
|
|
lua_setglobal (engine_lua_state,"engine_surface_draw_pixel");
|
2023-05-14 16:29:55 +00:00
|
|
|
lua_pushcfunction(engine_lua_state,engine_luaf_time_get);
|
|
|
|
lua_setglobal (engine_lua_state,"engine_time_get");
|
|
|
|
lua_pushcfunction(engine_lua_state,engine_luaf_time_sleep);
|
|
|
|
lua_setglobal (engine_lua_state,"engine_time_sleep");
|
|
|
|
lua_pushcfunction(engine_lua_state,engine_luaf_texture_create);
|
|
|
|
lua_setglobal (engine_lua_state,"engine_texture_create");
|
2023-05-14 18:40:19 +00:00
|
|
|
lua_pushcfunction(engine_lua_state,engine_luaf_texture_color_set);
|
|
|
|
lua_setglobal (engine_lua_state,"engine_texture_color_set");
|
|
|
|
lua_pushcfunction(engine_lua_state,engine_luaf_texture_draw_pixel);
|
|
|
|
lua_setglobal (engine_lua_state,"engine_texture_draw_pixel");
|
2023-05-14 16:29:55 +00:00
|
|
|
lua_pushcfunction(engine_lua_state,engine_luaf_texture_destroy);
|
|
|
|
lua_setglobal (engine_lua_state,"engine_texture_destroy");
|
|
|
|
lua_pushcfunction(engine_lua_state,engine_luaf_texture_render_2d);
|
|
|
|
lua_setglobal (engine_lua_state,"engine_texture_render_2d");
|
|
|
|
lua_pushcfunction(engine_lua_state,engine_luaf_texture_from_file);
|
|
|
|
lua_setglobal (engine_lua_state,"engine_texture_from_file");
|
2023-05-14 10:21:03 +00:00
|
|
|
|
|
|
|
luaL_loadfile(engine_lua_state,"assets/scripts/main.lua");
|
|
|
|
lua_call(engine_lua_state,0,0);
|
2023-05-14 18:40:19 +00:00
|
|
|
}
|