From 3f457498b9c39d40a16a0ec6328880854f8cf4de Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 26 Feb 2019 08:48:54 +0800 Subject: *misc --- Source/Asura.Engine/Graphics/Canvas.h | 43 +++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'Source/Asura.Engine/Graphics/Canvas.h') diff --git a/Source/Asura.Engine/Graphics/Canvas.h b/Source/Asura.Engine/Graphics/Canvas.h index c9adf2d..fc8a527 100644 --- a/Source/Asura.Engine/Graphics/Canvas.h +++ b/Source/Asura.Engine/Graphics/Canvas.h @@ -1,25 +1,64 @@ #ifndef __ASURA_ENGINE_CANVAS_H__ #define __ASURA_ENGINE_CANVAS_H__ +#include + +#include "GL.h" +#include "SimClass.h" #include "Texture.h" +#include "RenderTarget.h" namespace AsuraEngine { namespace Graphics { - class Canvas : public Texture + /// + /// Canvas也可以称为render texture,自身也可以作为texture渲染。 + /// + class Canvas final : public Texture, public RenderTarget, public SimClass { public: Canvas(); + /// + /// 绑定此canvas,设置为活动 + /// + void Bind(); + + /// + /// 设置为非活动,绑定回screen + /// + void Unbind(); + + void Render(int x, int y, int sx, int sy, int ox, int oy, int r) override; + + void Render(const Math::Rect& quad, int x, int y, int sx, int sy, int ox, int oy, int r) override; + + //---------------------------------------------------------------------------------------------------------- + + LUAX_DECL_FACTORY(SimCanvas); + + LUAX_DECL_METHOD(l_Bind); + LUAX_DECL_METHOD(l_Unbind); + + //---------------------------------------------------------------------------------------------------------- + private: - LUAX_DECL_FACTORY(SimCanvas); // AsuraEngine.SimCanvas + /// + /// Frame buffer object id. + /// + GLuint mFBO; }; + /// + /// Canvas别名为RenderTexture + /// + using RenderTexture = Canvas; + } } -- cgit v1.1-26-g67d0