From 250e30d73f09e9da2b5a81d0fbae63744ae12a73 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 2 Apr 2019 08:47:15 +0800 Subject: *misc --- source/libs/asura-lib-core/graphics/texture.h | 68 +++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 source/libs/asura-lib-core/graphics/texture.h (limited to 'source/libs/asura-lib-core/graphics/texture.h') diff --git a/source/libs/asura-lib-core/graphics/texture.h b/source/libs/asura-lib-core/graphics/texture.h new file mode 100644 index 0000000..c412b2e --- /dev/null +++ b/source/libs/asura-lib-core/graphics/texture.h @@ -0,0 +1,68 @@ +#ifndef __ASURA_ENGINE_TEXTURE_H__ +#define __ASURA_ENGINE_TEXTURE_H__ + +#include +#include +#include + +#include "../core_config.h" + +#include "render_state.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