From 084623519e95f0ab0cf4bc328b5fa736d679c5bd Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 31 Jul 2019 21:35:12 +0800 Subject: =?UTF-8?q?*=E4=BF=AE=E6=94=B9=E5=90=8D=E7=A7=B0=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/modules/asura-core/graphics/texture.h | 176 +++++++++++++-------------- 1 file changed, 87 insertions(+), 89 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 5d754eb..458e35a 100644 --- a/source/modules/asura-core/graphics/texture.h +++ b/source/modules/asura-core/graphics/texture.h @@ -9,95 +9,93 @@ #include "render_state.h" #include "gfx_device.h" -namespace AsuraEngine +namespace_begin(AsuraEngine) +namespace_begin(Graphics) + +class RenderTarget; + +/// UV采样方式 +enum WrapMode +{ + WRAP_MODE_REPEAT, + WRAP_MODE_MIRROR, + WRAP_MODE_CLAMPTOEDGE, + WRAP_MODE_CLAMPTOBORDER, +}; + +/// 滤波模式 +enum FilterMode { - namespace Graphics - { - - class RenderTarget; - - /// UV采样方式 - enum WrapMode - { - WRAP_MODE_REPEAT, - WRAP_MODE_MIRROR, - WRAP_MODE_CLAMPTOEDGE, - WRAP_MODE_CLAMPTOBORDER, - }; - - /// 滤波模式 - enum FilterMode - { - FILTER_MODE_NEAREST, - FILTER_MODE_LINEAR, - }; - - /// 图像数据的颜色格式 - enum ColorFormat - { - COLOR_FORMAT_UNKNOWN, - COLOR_FORMAT_RGBA8, ///< RGBA都是8bits int - COLOR_FORMAT_RGBA32F, ///< RGBA都是32bits float - }; - - /// 纹理格式,GPU内部和CPU外部格式 - struct TextureFormat - { - GLenum internalformat; ///< GPU内部格式 - GLenum externalformat; ///< CPU外部格式 - GLenum type; ///< 外部格式每个channel数值类型 - }; - - /// - /// 2D纹理抽象类,在2d mesh和render target中被使用。Texture的渲染原点在左上角,游戏里面的上层会以笛卡尔 - /// 坐标系为标准。在Editor里面界面和组件也是以左上角为原点,这样是为了方便。 - /// - ASURA_ABSTRACT class Texture : public AEScripting::Object - { - public: - - LUAX_DECL_ABSTRACT_FACTORY(Texture); - - Texture(); - virtual ~Texture(); - - GLuint GetGLTexture() const; - - void SetFilterMode(FilterMode min, FilterMode mag); - void SetWrapMode(WrapMode wrapMode); - - void GetFilterMode(); - void GetWrapMode(); - - /// 如果设置U或V方向filter为 - bool IsGenMipmap(); - - protected: - - /// 转换color format为texture format。 - TextureFormat ConvertColorFormat(const ColorFormat& colorformat); - - GLuint m_TexID; - FilterMode m_MinFilter; - FilterMode m_MagFilter; - WrapMode m_WrapMode; - bool m_IsGenMipmap; - - LUAX_DECL_ENUM(ColorFormat, 1); - LUAX_DECL_ENUM(FilterMode, 1); - LUAX_DECL_ENUM(WrapMode, 1); - - LUAX_DECL_METHOD(_SetFilterMode); - LUAX_DECL_METHOD(_SetWrapMode); - LUAX_DECL_METHOD(_GetFilterMode); - LUAX_DECL_METHOD(_GetWrapMode); - LUAX_DECL_METHOD(_IsGenMipmap); - - }; - - typedef Texture Drawable; - - } -} + FILTER_MODE_NEAREST, + FILTER_MODE_LINEAR, +}; + +/// 图像数据的颜色格式 +enum ColorFormat +{ + COLOR_FORMAT_UNKNOWN, + COLOR_FORMAT_RGBA8, ///< RGBA都是8bits int + COLOR_FORMAT_RGBA32F, ///< RGBA都是32bits float +}; + +/// 纹理格式,GPU内部和CPU外部格式 +struct TextureFormat +{ + GLenum internalformat; ///< GPU内部格式 + GLenum externalformat; ///< CPU外部格式 + GLenum type; ///< 外部格式每个channel数值类型 +}; + +/// +/// 2D纹理抽象类,在2d mesh和render target中被使用。Texture的渲染原点在左上角,游戏里面的上层会以笛卡尔 +/// 坐标系为标准。在Editor里面界面和组件也是以左上角为原点,这样是为了方便。 +/// +ASURA_ABSTRACT class Texture : public AEScripting::Object +{ +public: + + LUAX_DECL_ABSTRACT_FACTORY(Texture); + + Texture(); + virtual ~Texture(); + + GLuint GetGLTexture() const; + + void SetFilterMode(FilterMode min, FilterMode mag); + void SetWrapMode(WrapMode wrapMode); + + void GetFilterMode(); + void GetWrapMode(); + + /// 如果设置U或V方向filter为 + bool IsGenMipmap(); + +protected: + + /// 转换color format为texture format。 + TextureFormat ConvertColorFormat(const ColorFormat& colorformat); + + GLuint m_TexID; + FilterMode m_MinFilter; + FilterMode m_MagFilter; + WrapMode m_WrapMode; + bool m_IsGenMipmap; + + LUAX_DECL_ENUM(ColorFormat, 1); + LUAX_DECL_ENUM(FilterMode, 1); + LUAX_DECL_ENUM(WrapMode, 1); + + LUAX_DECL_METHOD(_SetFilterMode); + LUAX_DECL_METHOD(_SetWrapMode); + LUAX_DECL_METHOD(_GetFilterMode); + LUAX_DECL_METHOD(_GetWrapMode); + LUAX_DECL_METHOD(_IsGenMipmap); + +}; + +typedef Texture Drawable; + +namespace_end +namespace_end #endif \ No newline at end of file -- cgit v1.1-26-g67d0