LuaEngine/LuaEngine.cpp
Kiritow 4cd800084a LuaEngine v0.5.3
Improved Thread and Channel
Add ShareableResource.
Channels now support push and get Surface objects as ShareableResource.
  Some objects are not allowed to be used out of main thread. Thus not all SDL objects are planned to be shareable via Channels.
More Surface methods.
2020-07-01 21:11:32 +08:00

57 lines
919 B
C++

#include "include.h"
#include <cstdlib>
#include <ctime>
void InitLuaEngine(lua_State* L)
{
InitEvent(L);
InitWindow(L);
InitRenderer(L);
InitFont(L);
InitMusic(L);
InitCommon(L);
InitTCPSocket(L);
InitUDPSocket(L);
InitNetwork(L);
InitSocketSelector(L);
InitThread(L);
InitChannel(L);
InitSurface(L);
}
lua_State* CreateLuaEngine()
{
lua_State* L = luaL_newstate();
luaL_openlibs(L);
InitLuaEngine(L);
return L;
}
void InitEngine()
{
SDL_Init(SDL_INIT_EVERYTHING);
IMG_Init(IMG_INIT_PNG | IMG_INIT_JPG);
TTF_Init();
Mix_Init(MIX_INIT_MP3 | MIX_INIT_OGG);
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) == -1)
{
SDL_Log("Mix_OpenAudio: %s\n", Mix_GetError());
exit(2);
}
Mix_AllocateChannels(16);
// Stop text input event
SDL_StopTextInput();
PlatInit();
srand(time(NULL));
}
void CloseEngine()
{
Mix_CloseAudio();
Mix_Quit();
TTF_Quit();
IMG_Quit();
SDL_Quit();
}