diff options
Diffstat (limited to 'Runtime/Scripting')
-rw-r--r-- | Runtime/Scripting/Rendering/Rendering.bind.cpp | 22 | ||||
-rw-r--r-- | Runtime/Scripting/Resource/Resource.bind.cpp | 25 |
2 files changed, 23 insertions, 24 deletions
diff --git a/Runtime/Scripting/Rendering/Rendering.bind.cpp b/Runtime/Scripting/Rendering/Rendering.bind.cpp index 40b3ac5..9bb6242 100644 --- a/Runtime/Scripting/Rendering/Rendering.bind.cpp +++ b/Runtime/Scripting/Rendering/Rendering.bind.cpp @@ -2,29 +2,7 @@ #include "Runtime/Graphics/Texture.h" #include "Runtime/Graphics/ImageData.h" -#define STB_IMAGE_IMPLEMENTATION -#include "ThirdParty/stb/stb_image.h" - -// imgData = Rendering.LoadImage(path) -int LoadImage(lua_State* L) -{ - LUA_BIND_STATE(L); - - const char* path = state.GetValue<const char*>(1, ""); - - stbi_set_flip_vertically_on_load(true); - ImageData* data = new ImageData(state.GetVM()); - int channels; - data->pixels = stbi_load(path, &data->width, &data->height, &channels, 0);
- data->format = ImageData::EPixelFormat::RGB; - data->type = ImageData::EPixelElementType::UNSIGNED_BYTE; - - data->PushUserdata(state); - return 1; -} - static luaL_Reg funcs[] = { - {"LoadImage", LoadImage}, {0, 0} }; diff --git a/Runtime/Scripting/Resource/Resource.bind.cpp b/Runtime/Scripting/Resource/Resource.bind.cpp index 785115a..6f9c0bb 100644 --- a/Runtime/Scripting/Resource/Resource.bind.cpp +++ b/Runtime/Scripting/Resource/Resource.bind.cpp @@ -1,11 +1,14 @@ #include "Runtime/Lua/LuaHelper.h" #include "Runtime/Debug/Log.h" #include "Runtime/FileSystem/ImageJobs.h" +#include "Runtime/Graphics/ImageData.h" +#define STB_IMAGE_IMPLEMENTATION +#include "ThirdParty/stb/stb_image.h" using namespace LuaBind; // Resource.LoadImageDataAsync(path, callback) -int ReadImageDataAsync(lua_State* L) +int LoadImageDataJob(lua_State* L) { LUA_BIND_STATE(L); LUA_BIND_CHECK(L, "SF"); @@ -19,8 +22,26 @@ int ReadImageDataAsync(lua_State* L) return 0; } +int LoadImageData(lua_State* L) +{ + LUA_BIND_STATE(L); + + const char* path = state.GetValue<const char*>(1, ""); + + stbi_set_flip_vertically_on_load(true); + ImageData* data = new ImageData(state.GetVM()); + int channels; + data->pixels = stbi_load(path, &data->width, &data->height, &channels, 0); + data->format = ImageData::EPixelFormat::RGB; + data->type = ImageData::EPixelElementType::UNSIGNED_BYTE; + + data->PushUserdata(state); + return 1; +} + static luaL_Reg funcs[] = { - {"ReadImageDataAsync", ReadImageDataAsync}, + { "LoadImageData", LoadImageData }, + { "LoadImageDataJob", LoadImageDataJob }, {0, 0} }; |