diff options
Diffstat (limited to 'Runtime/Scripting/Resource/Resource.bind.cpp')
-rw-r--r-- | Runtime/Scripting/Resource/Resource.bind.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Runtime/Scripting/Resource/Resource.bind.cpp b/Runtime/Scripting/Resource/Resource.bind.cpp new file mode 100644 index 0000000..b4ba025 --- /dev/null +++ b/Runtime/Scripting/Resource/Resource.bind.cpp @@ -0,0 +1,41 @@ +#include "Runtime/Lua/LuaHelper.h" +#include "Runtime/Debug/Log.h" +#include "Runtime/FileSystem/ImageJobs.h" + +using namespace LuaBind; + +// Resource.LoadImageDataAsync(path, callback) +int ReadImageDataAsync(lua_State* L) +{ + LUA_BIND_STATE(L); + LUA_BIND_CHECK(L, "TF"); + + cc8* path = state.GetValue(1, ""); + + ReadImageFileJob* job = new ReadImageFileJob(state.GetVM(), 2, path); + + JobSystem::Instance()->AddJobAtEnd(job); + + return 0; +} + +static luaL_Reg funcs[] = { + {"ReadImageDataAsync", ReadImageDataAsync}, + {0, 0} +}; + +int luaopen_GameLab_Engine_Resource(lua_State* L) +{ + log_info("Scripting", "luaopen_GameLab_Engine_Resource()"); + + LUA_BIND_STATE(L); + + state.PushGlobalNamespace(); + state.PushNamespace("GameLab"); + state.PushNamespace("Engine"); + state.PushNamespace("Resource"); + + state.RegisterMethods(funcs); + + return 1; +}
\ No newline at end of file |