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/window.h | 85 +++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 Source/Asura.Engine/graphics/window.h (limited to 'Source/Asura.Engine/graphics/window.h') diff --git a/Source/Asura.Engine/graphics/window.h b/Source/Asura.Engine/graphics/window.h new file mode 100644 index 0000000..973fd98 --- /dev/null +++ b/Source/Asura.Engine/graphics/window.h @@ -0,0 +1,85 @@ +#ifndef __ASURA_ENGINE_WINDOW_H__ +#define __ASURA_ENGINE_WINDOW_H__ + +#include "SDL2/Sdl.h" +#include "Graphics/RenderTarget.h" +#include "Math/Vector2.hpp" +#include "Scripting/Portable.h" + +namespace AsuraEngine +{ + namespace Graphics + { + + enum WindowStyle + { + WINDOW_STYLE_FULLSCREEN = 1 << 1, + }; + + /// + /// 窗口,支持多窗口。在编辑器下需要多个窗口支持,runner只需要一个窗口。 + /// + class Window ASURA_FINAL + : public RenderTarget + , public Scripting::Portable + { + public: + + Window(WindowStyle style); + + ~Window(); + + SDL_Window* GetSDLWindowHandle(); + + void SetSize(uint width, uint height); + + void SetPosition(int x, int y); + + void SetTitle(const std::string& title); + + void SetWindowStyle(WindowStyle style); + + void Show(); + + void Hide(); + + /// + /// 如果是开启双缓冲的窗口,需要交换缓冲区来展示到前台 + /// + void SwapRenderBuffer(); + + void Clear(const Color& col = Color::Black) override; + + void Clear(const Math::Recti& quad, const Color& col = Color::Black) override; + + void Draw(const Drawable* texture, const RenderState& state) override; + + void Draw(const Drawable* texture, const Math::Recti& quad, const RenderState& state) override; + + private: + + /// + /// SDL window handle. + /// + SDL_Window* mWindowHandle; + + Math::Vector2i mPosition; + + Math::Vector2i mSize; + + public: + + //---------------------------------------------------------------------------------------------------------- + + LUAX_DECL_FACTORY(Window); + + //---------------------------------------------------------------------------------------------------------- + + }; + + using RenderWindow = Window; + + } +} + +#endif \ No newline at end of file -- cgit v1.1-26-g67d0