From 8644e03586ac9c39741f62cbcbce87b18805538c Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 14 Mar 2019 23:12:54 +0800 Subject: =?UTF-8?q?*=E5=A4=A7=E5=B0=8F=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/Asura.Engine/graphics/texture.h | 66 ++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 Source/Asura.Engine/graphics/texture.h (limited to 'Source/Asura.Engine/graphics/texture.h') diff --git a/Source/Asura.Engine/graphics/texture.h b/Source/Asura.Engine/graphics/texture.h new file mode 100644 index 0000000..81aa469 --- /dev/null +++ b/Source/Asura.Engine/graphics/texture.h @@ -0,0 +1,66 @@ +#ifndef __ASURA_ENGINE_TEXTURE_H__ +#define __ASURA_ENGINE_TEXTURE_H__ + +#include "Config.h" +#include "Math/Rect.hpp" +#include "Math/Vector2.hpp" +#include "Scripting/Luax.hpp" +#include "RenderState.h" +#include "GL.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + class RenderTarget; + + /// + /// 2D纹理抽象类,在2d mesh和render target中被使用。Texture的渲染原点在左上角,游戏里面的上层会以笛卡尔坐标系为标准。 + /// 在Editor里面界面和组件也是以左上角为原点,这样是为了方便。 + /// + ASURA_ABSTRACT class Texture + { + public: + + Texture(); + + virtual ~Texture(); + + GLuint GetGLTextureHandle() const; + + /// + /// 渲染整个texture到rt上,原点在左上角,向右,向下延伸 + /// + virtual void Render(const RenderTarget* rt, const RenderState& state) = 0; + + /// + /// 渲染texture的一部分到rt上,原点在左上角,向右,向下延伸。 + /// + virtual void Render(const RenderTarget* rt, const Math::Rectf& quad, const RenderState& state) = 0; + + /// + /// 设置过滤方式 + /// + void SetSmooth(bool smooth); + + /// + /// 设置重复方式 + /// + void SetRepeated(); + + protected: + + /// + /// OpenGL texture handle。 + /// + GLuint mTextureHandle; + + }; + + using Drawable = Texture; + + } +} + +#endif \ No newline at end of file -- cgit v1.1-26-g67d0