From 0c391fdbce5a079cf03e483eb6174dd47806163d Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 7 Aug 2019 21:08:47 +0800 Subject: *misc --- Source/modules/asura-core/Graphics/Canvas.h | 73 +++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Source/modules/asura-core/Graphics/Canvas.h (limited to 'Source/modules/asura-core/Graphics/Canvas.h') diff --git a/Source/modules/asura-core/Graphics/Canvas.h b/Source/modules/asura-core/Graphics/Canvas.h new file mode 100644 index 0000000..de02b9d --- /dev/null +++ b/Source/modules/asura-core/Graphics/Canvas.h @@ -0,0 +1,73 @@ +#ifndef _ASURA_ENGINE_CANVAS_H_ +#define _ASURA_ENGINE_CANVAS_H_ + +#include +#include +#include +#include + +#include "GfxDevice.h" +#include "Texture.h" +#include "RenderTarget.h" +#include "RenderState.h" + +namespace_begin(AsuraEngine) +namespace_begin(Graphics) + + +/// +/// Canvas也可以称为render texture,自身也可以作为texture渲染。 +/// +class Canvas ASURA_FINAL + : public Scripting::Portable +{ +public: + + Canvas(); + + ~Canvas(); + + /// + /// 设置render texture的大小 + /// + void SetSize(uint w, uint h) ASURA_THROW(Exception); + + void Clear(const Color& col = Color::Black) override; +/* + void Clear(const Math::Recti& quad, const Color& col = Color::Black) override; +*/ + void Render(const RenderTarget* rt, const Math::Vector2i& pos, const Math::Vector2i& scale, const Math::Vector2i& center, float rot); + + void Render(const RenderTarget* rt, const Math::Rectf& quad, const Math::Vector2i& pos, const Math::Vector2i& scale, const Math::Vector2i& center, float rot); + + void Draw(const Drawable* texture, const RenderState& state); + + void Draw(const Drawable* texture, const Math::Recti& quad, const RenderState& state); + +private: + + GLuint m_FBO; + + GLuint m_TexID; + + uint m_Width, m_Height; + +luaxport: + + LUAX_DECL_FACTORY(Canvas, RenderTarget); + + LUAX_DECL_METHOD(_SetSize); + LUAX_DECL_METHOD(_Bind); + LUAX_DECL_METHOD(_Unbind); + +}; + +/// +/// Canvas别名为RenderTexture +/// +typedef Canvas RenderTexture; + +} // Graphics +} // AsuraEngine + +#endif \ No newline at end of file -- cgit v1.1-26-g67d0