Krig Game Engine
Loading...
Searching...
No Matches
api.h
1#ifndef _API_H_
2#define _API_H_
3
4#define luaL_setfuncs krig_custom_setfuncs
5
6
7extern "C" {
8 #include "luajit-2.1/lua.h"
9 #include "luajit-2.1/lualib.h"
10 #include "luajit-2.1/lauxlib.h"
11}
12
13#if !defined LUA_VERSION_NUM || LUA_VERSION_NUM==501
14/*
15 * Adapted from Lua 5.2.0
16 */
17inline void krig_custom_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
18 luaL_checkstack(L, nup+1, "too many upvalues");
19 for (; l->name != NULL; l++) { /* fill the table with given functions */
20 int i;
21 lua_pushstring(L, l->name);
22 for (i = 0; i < nup; i++) /* copy upvalues to the top */
23 lua_pushvalue(L, -(nup+1));
24 lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */
25 lua_settable(L, -(nup + 3));
26 }
27 lua_pop(L, nup); /* remove upvalues */
28}
29#endif
30
31#include "krig_game_engine.h"
32#include "Object.h"
33
34// Macros /////////////////////////////////////////////////////////////////////
35#define SCRIPT_CALLBACK_ON_LOAD "on_load"
36#define SCRIPT_CALLBACK_ON_UPDATE "on_update"
37#define SCRIPT_CALLBACK_ON_DRAW "on_draw"
38#define SCRIPT_CALLBACK_ON_DRAW_SCREEN "on_draw_screen"
39#define SCRIPT_CALLBACK_ON_COLLISION "on_collision"
40#define SCRIPT_CALLBACK_ON_UNLOAD "on_unload"
41
42// Functions /////// ///////////////////////////////////////////////////////////
43Vector loadVector(lua_State *L);
44Vector loadVector(lua_State *L, int &index);
45Quaternion loadQuaternion(lua_State *L, const int &index);
46Object* loadObject(lua_State *L, const int &index);
47void loadArray(lua_State *L, float array[], int len, int index);
48void returnVector(lua_State *L, const Vector &t);
49void returnQuaternion(lua_State *L, const Quaternion &t);
50void returnObject(lua_State *L, Object* object);
51void returnArray(lua_State *L, float array[], int len);
52void luaopen_krigApi(lua_State *L);
53
54#endif
Base game object from which all concrete types are defined.
Definition Object.h:35
Definition Quaternion.h:18
Definition Vector.h:15