From a077eb38b01292611f4f6031b75e3e2c1c20f06e Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 16 Aug 2019 08:54:08 +0800 Subject: *misc --- source/modules/asura-core/graphics/texture.h | 38 +++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'source/modules/asura-core/graphics/texture.h') diff --git a/source/modules/asura-core/graphics/texture.h b/source/modules/asura-core/graphics/texture.h index 76b9a8f..572fad4 100644 --- a/source/modules/asura-core/graphics/texture.h +++ b/source/modules/asura-core/graphics/texture.h @@ -3,6 +3,7 @@ #include #include +#include #include "../CoreConfig.h" @@ -14,6 +15,17 @@ namespace_begin(Graphics) class RenderTarget; +/// 图片数据 +class ImageData +{ +public: + uint8* GetData(); +private: + int m_Format; + uint8* m_ImageData; + Vector2i m_ImageSize; +}; + /// UV采样方式 enum WrapMode { @@ -34,8 +46,8 @@ enum FilterMode enum ColorFormat { COLOR_FORMAT_UNKNOWN, - COLOR_FORMAT_RGBA8, ///< RGBA都是8bits int - COLOR_FORMAT_RGBA32F, ///< RGBA都是32bits float + COLOR_FORMAT_RGBA8, + COLOR_FORMAT_RGBA32F, }; /// 纹理格式,GPU内部和CPU外部格式 @@ -50,11 +62,14 @@ struct TextureFormat /// 2D纹理抽象类,在2d mesh和render target中被使用。Texture的渲染原点在左上角,游戏里面的上层会以笛卡尔 /// 坐标系为标准。在Editor里面界面和组件也是以左上角为原点,这样是为了方便。 /// -ASURA_ABSTRACT class Texture : public AEScripting::Object +class Texture : public AEScripting::Object { public: - LUAX_DECL_ABSTRACT_FACTORY(Texture); + LUAX_DECL_FACTORY(Texture); + + // Texture generator + static Texture* GenerateTexture(); Texture(); virtual ~Texture(); @@ -67,9 +82,12 @@ public: void GetFilterMode(); void GetWrapMode(); - /// 如果设置U或V方向filter为 bool IsGenMipmap(); + int GetWidth(); + int GetHeight(); + Vector2i GetSize(); + protected: /// 转换color format为texture format。 @@ -79,7 +97,12 @@ protected: FilterMode m_MinFilter; FilterMode m_MagFilter; WrapMode m_WrapMode; + int m_UsageMode; bool m_IsGenMipmap; + Vector2f m_TexelSize; + Vector2f m_UVScale; + +luaxport: LUAX_DECL_ENUM(ColorFormat, 1); LUAX_DECL_ENUM(FilterMode, 1); @@ -90,11 +113,12 @@ protected: LUAX_DECL_METHOD(_GetFilterMode); LUAX_DECL_METHOD(_GetWrapMode); LUAX_DECL_METHOD(_IsGenMipmap); + LUAX_DECL_METHOD(_GetWidth); + LUAX_DECL_METHOD(_GetHeight); + LUAX_DECL_METHOD(_GetSize); }; -typedef Texture Drawable; - namespace_end namespace_end -- cgit v1.1-26-g67d0