From 8164adb15b76f537f8b6c78b9992786b61d61cc8 Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 30 Mar 2019 21:49:29 +0800 Subject: *misc --- source/modules/asura-core/graphics/texture.h | 74 +++++++++++++++++++++------- 1 file changed, 55 insertions(+), 19 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 81ced9f..a76e1d4 100644 --- a/source/modules/asura-core/graphics/texture.h +++ b/source/modules/asura-core/graphics/texture.h @@ -1,9 +1,8 @@ -#ifndef __ASURA_ENGINE_TEXTURE_H__ -#define __ASURA_ENGINE_TEXTURE_H__ +#ifndef __ASURA_TEXTURE_H__ +#define __ASURA_TEXTURE_H__ #include #include -#include #include "../core_config.h" @@ -17,20 +16,59 @@ namespace AsuraEngine class RenderTarget; + enum WrapMode + { + WRAP_MODE_REPEAT, + WRAP_MODE_MIRROR, + WRAP_MODE_CLAMPTOEDGE, + WRAP_MODE_CLAMPTOBORDER, + //WRAP_MODE_PERAXIS, // UV方向有不同的上面4种值 + }; + + enum FilterMode + { + FILTER_MODE_NEAREST, + FILTER_MODE_LINEAR, + }; + /// - /// 2D纹理抽象类,在2d mesh和render target中被使用。Texture的渲染原点在左上角,游戏里面的上层会以笛卡尔坐标系为标准。 - /// 在Editor里面界面和组件也是以左上角为原点,这样是为了方便。 + /// 图像数据的颜色格式 + /// + enum ColorFormat + { + COLOR_FORMAT_UNKNOWN, + + COLOR_FORMAT_RGBA8, ///< RGBA都是8bits int + COLOR_FORMAT_RGBA32F, ///< RGBA都是32bits float + }; + + /// + /// 2D纹理抽象类,在2d mesh和render target中被使用。Texture的渲染原点在左上角,游戏里 + /// 面的上层会以笛卡尔坐标系为标准。在Editor里面界面和组件也是以左上角为原点,这样是为了 + /// 方便。 /// ASURA_ABSTRACT class Texture { public: - Texture(); + LUAX_DECL_ABSTRACT_FACTORY(); + Texture(); virtual ~Texture(); GLuint GetGLTextureHandle() const; + void SetFilterMode(FilterMode min, FilterMode mag); + void SetWrapMode(WrapMode wrapMode); + + void GetFilterMode(); + void GetWrapMode(); + + /// + /// 如果设置U或V方向filter为 + /// + void IsGenMipmap(); + /// /// 渲染整个texture到rt上,原点在左上角,向右,向下延伸 /// @@ -41,22 +79,20 @@ namespace AsuraEngine /// virtual void Render(const RenderTarget* rt, const Math::Rectf& quad, const RenderState& state) = 0; - /// - /// 设置过滤方式 - /// - void SetSmooth(bool smooth); + protected: - /// - /// 设置重复方式 - /// - void SetRepeated(); + LUAX_DECL_ENUM(ColorFormat); + LUAX_DECL_ENUM(FilterMode); + LUAX_DECL_ENUM(WrapMode); - protected: + GLuint mTexHandle; - /// - /// OpenGL texture handle。 - /// - GLuint mTextureHandle; + FilterMode mMinFilter; + FilterMode mMagFilter; + + WrapMode mWrapMode; + + bool mIsGenMipmap; }; -- cgit v1.1-26-g67d0