diff options
author | chai <chaifix@163.com> | 2021-10-26 19:33:40 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-10-26 19:33:40 +0800 |
commit | 051abd04e4527095ef15412939450fbe504daebe (patch) | |
tree | 30a966d104ee866bc135cce58b4a5fa561c8c4e7 /Runtime/Graphics/ImageData.h | |
parent | b1228baf73f6dc3336e24afbf36087e15730732a (diff) |
+texture & imagedata
Diffstat (limited to 'Runtime/Graphics/ImageData.h')
-rw-r--r-- | Runtime/Graphics/ImageData.h | 49 |
1 files changed, 39 insertions, 10 deletions
diff --git a/Runtime/Graphics/ImageData.h b/Runtime/Graphics/ImageData.h index af44f11..4663e0e 100644 --- a/Runtime/Graphics/ImageData.h +++ b/Runtime/Graphics/ImageData.h @@ -3,27 +3,54 @@ #include <vector> #include "Runtime/Threading/Job.h" +#include "Runtime/Lua/LuaHelper.h" // 图片像素数据 -class ImageData +class ImageData : public LuaBind::NativeClass<ImageData> { public: - enum ImageFormat + enum EPixelFormat { - ImageFormat_Rgba_Int, - ImageFormat_Rgba_Float, + RGBA, + RGB, + R, + RG, + BGR, + BGRA }; -private: - void* m_Data; + enum EPixelElementType + { + UNSIGNED_BYTE, + UNSIGNED_INT, + BYTE, + INT, + FLOAT, + }; + ImageData(LuaBind::VM* vm) + : LuaBind::NativeClass<ImageData>(vm) + { + } + + void* pixels; // 像素数据,格式和类型参考 http://docs.gl/gl3/glTexImage2D pixel data的format和type
+ EPixelFormat format;
+ EPixelElementType type;
+ int width, height;
+
+private:
+ LUA_BIND_DECL_CLASS(ImageData);
+
+ LUA_BIND_DECL_METHOD(_GetWidth); + LUA_BIND_DECL_METHOD(_GetHeight); + LUA_BIND_DECL_METHOD(_GetSize); }; -enum ImageDataAsyncError +enum EImageDataAsyncError { - ImageDataAsyncError_NoFile = 1, - ImageDataAsyncError_ParseFailed = 2, - ImageDataAsyncError_InvalidFormat = 3, + NoFile = 1, + ParseFailed = 2, + InvalidFormat = 3, }; struct ImageDataRequest @@ -42,6 +69,8 @@ namespace ImageDataUtil ImageDataRequest* LoadAsync(std::vector<const char*> paths); } +// 在工作线程最多只能走到读取->解码完,提交到GPU还得主线程做 + class ReadImageFilesJob : public Job { |