void videoPushPoint(lua_State *L, const SDL_Point *point) { lua_createtable(L, 2, 2); tableSetInt(L, -1, "x", point->x); tableSetInt(L, -1, "y", point->y); }
void videoPushColorRGB(lua_State *L, const SDL_Color *color) { lua_createtable(L, 0, 4); tableSetInt(L, -1, "r", color->r); tableSetInt(L, -1, "g", color->g); tableSetInt(L, -1, "b", color->b); tableSetInt(L, -1, "a", color->a); }
void videoPushRect(lua_State *L, const SDL_Rect *rect) { lua_createtable(L, 4, 4); tableSetInt(L, -1, "w", rect->w); tableSetInt(L, -1, "h", rect->h); tableSetInt(L, -1, "x", rect->x); tableSetInt(L, -1, "y", rect->y); }
int EXPORT luaopen_SDL(lua_State *L) { int i; SDL_version ver; /* General functions */ commonNewLibrary(L, functions); /* Library categories */ for (i = 0; libraries[i].functions != NULL; ++i) commonBindLibrary(L, libraries[i].functions); /* Enumerations */ for (i = 0; enums[i].values != NULL; ++i) commonBindEnum(L, -1, enums[i].name, enums[i].values); /* Object oriented data */ for (i = 0; objects[i].object != NULL; ++i) commonBindObject(L, objects[i].object); /* Store the version */ SDL_GetVersion(&ver); tableSetInt(L, -1, "VERSION_MAJOR", ver.major); tableSetInt(L, -1, "VERSION_MINOR", ver.minor); tableSetInt(L, -1, "VERSION_PATCH", ver.patch); tableSetInt(L, -1, "VERSION_BINDING", 4); tableSetInt(L, -1, "VERSION_BINDING_PATCH", 1); lua_newtable(L); tableSetInt(L, -1, "major", ver.major); tableSetInt(L, -1, "minor", ver.minor); tableSetInt(L, -1, "patch", ver.patch); lua_setfield(L, -2, "version"); lua_newtable(L); tableSetInt(L, -1, "major", VERSION_BINDING_MAJOR); tableSetInt(L, -1, "minor", VERSION_BINDING_MINOR); lua_setfield(L, -2, "binding"); if (ChannelMutex == NULL && (ChannelMutex = SDL_CreateMutex()) == NULL) return luaL_error(L, SDL_GetError()); return 1; }