From 051abd04e4527095ef15412939450fbe504daebe Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 26 Oct 2021 19:33:40 +0800 Subject: +texture & imagedata --- Runtime/Graphics/ImageData.h | 49 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 10 deletions(-) (limited to 'Runtime/Graphics/ImageData.h') 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 #include "Runtime/Threading/Job.h" +#include "Runtime/Lua/LuaHelper.h" // 图片像素数据 -class ImageData +class ImageData : public LuaBind::NativeClass { 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(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 paths); } +// 在工作线程最多只能走到读取->解码完,提交到GPU还得主线程做 + class ReadImageFilesJob : public Job { -- cgit v1.1-26-g67d0