diff options
author | chai <chaifix@163.com> | 2019-08-07 21:08:47 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-08-07 21:08:47 +0800 |
commit | 0c391fdbce5a079cf03e483eb6174dd47806163d (patch) | |
tree | b06cd7a9d0ae0d9bb9e82f3dcb786dfce11f8628 /Source/modules/asura-core/Window/Window.cpp | |
parent | 9686368e58e25cbd6dc37d686bdd2be3f80486d6 (diff) |
*misc
Diffstat (limited to 'Source/modules/asura-core/Window/Window.cpp')
-rw-r--r-- | Source/modules/asura-core/Window/Window.cpp | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/Source/modules/asura-core/Window/Window.cpp b/Source/modules/asura-core/Window/Window.cpp new file mode 100644 index 0000000..d75b9a7 --- /dev/null +++ b/Source/modules/asura-core/Window/Window.cpp @@ -0,0 +1,104 @@ +#include <asura-base/Exception.h> + +#include "window.h" + +#include "WindowImplSDL.h" +#include "WindowImplGlew.h" +#include "WindowImplGlut.h" + +namespace_begin(AsuraEngine) +namespace_begin(Window) + + Window::Window() + : m_Impl(nullptr) + { + } + + Window::~Window() + { + if (m_Impl) + delete m_Impl; + } + +#define try_init_window(impl) \ + if (!m_Impl) \ + { \ + m_Impl = new impl(); \ + if (!m_Impl->Init(config)) \ + { \ + delete m_Impl; \ + m_Impl = nullptr; \ + } \ + } + + bool Window::Init(const WindowConfig& config) + { + ASSERT(!m_Impl); +#if ASURA_WINDOW_SDL + try_init_window(WindowImplSDL); +#endif + return m_Impl != nullptr; + } + + void Window::Exit() + { + if (m_Impl) + delete m_Impl; + } + + void Window::SetPosition(int x, int y) + { + ASSERT(m_Impl); + m_Impl->SetPosition(x, y); + } + + void Window::SetTitle(const std::string& title) + { + ASSERT(m_Impl); + m_Impl->SetTitils(title); + } + + void Window::Show() + { + ASSERT(m_Impl); + m_Impl->Show(); + } + + void Window::Hide() + { + ASSERT(m_Impl); + m_Impl->Hide(); + } + + void Window::SwapRenderBuffer() + { + ASSERT(m_Impl); + m_Impl->SwapRenderBuffer(); + } + + void Window::Clear(const AEGraphics::Color& col /*= AEGraphics::Color::Black*/) + { + ASSERT(m_Impl); + glClearColor(col.r, col.g, col.b, col.a); + } + + //void Window::Clear(const Math::Recti& quad, const AEGraphics::Color& col /*= AEGraphics::Color::Black*/) + //{ + // ASSERT(m_Impl); + + //} + + void Window::Draw(const AEGraphics::Drawable* texture, const AEGraphics::RenderState& state) + { + ASSERT(m_Impl); + + } +/* + void Window::Draw(const AEGraphics::Drawable* texture, const Math::Recti& quad, const AEGraphics::RenderState& state) + { + ASSERT(m_Impl); + + } +*/ + } +} |