summaryrefslogtreecommitdiff
path: root/Runtime/Scripting/Resource
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-10-26 23:20:45 +0800
committerchai <chaifix@163.com>2021-10-26 23:20:45 +0800
commit208e23de77ad6d104f13a0bb591ae16c4a805fe9 (patch)
tree29499de463a6d3407d2e555c1ad9b743f07097b1 /Runtime/Scripting/Resource
parent8b419dc90cb4e01fa1810e0f84dcdcfe2bd822ad (diff)
*load image async
Diffstat (limited to 'Runtime/Scripting/Resource')
-rw-r--r--Runtime/Scripting/Resource/Resource.bind.cpp41
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