diff options
author | chai <chaifix@163.com> | 2019-04-02 08:47:15 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-04-02 08:47:15 +0800 |
commit | 250e30d73f09e9da2b5a81d0fbae63744ae12a73 (patch) | |
tree | 0f55daf334c073e1779d7a1284799a2056aad714 /source/modules/asura-core/window/window.cpp | |
parent | 66fe16dd5ed57ae958fc25158d0defae2e6fae6a (diff) |
*misc
Diffstat (limited to 'source/modules/asura-core/window/window.cpp')
-rw-r--r-- | source/modules/asura-core/window/window.cpp | 106 |
1 files changed, 106 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..99433d5 --- /dev/null +++ b/source/modules/asura-core/window/window.cpp @@ -0,0 +1,106 @@ +#include <asura-utils/exceptions/exception.h> + +#include "window.h" + +#include "window_impl_sdl.h" +#include "window_impl_glew.h" +#include "window_impl_glut.h" + +namespace AsuraEngine +{ + namespace Window + { + + Window::Window() + : mImpl(nullptr) + { + } + + Window::~Window() + { + if (mImpl) + delete mImpl; + } + +#define try_init_window(impl) \ + if (!mImpl) \ + { \ + mImpl = new impl(); \ + if (!mImpl->Init(config)) \ + { \ + delete mImpl; \ + mImpl = nullptr; \ + } \ + } + + bool Window::Init(const WindowConfig& config) + { + ASSERT(!mImpl); +#if ASURA_WINDOW_SDL + try_init_window(WindowImplSDL); +#endif + return mImpl != nullptr; + } + + void Window::Exit() + { + if (mImpl) + delete mImpl; + } + + void Window::SetPosition(int x, int y) + { + ASSERT(mImpl); + mImpl->SetPosition(x, y); + } + + void Window::SetTitle(const std::string& title) + { + ASSERT(mImpl); + mImpl->SetTitils(title); + } + + void Window::Show() + { + ASSERT(mImpl); + mImpl->Show(); + } + + void Window::Hide() + { + ASSERT(mImpl); + mImpl->Hide(); + } + + void Window::SwapRenderBuffer() + { + ASSERT(mImpl); + mImpl->SwapRenderBuffer(); + } + + void Window::Clear(const AEGraphics::Color& col /*= AEGraphics::Color::Black*/) + { + ASSERT(mImpl); + glClearColor(col.r, col.g, col.b, col.a); + } + + void Window::Clear(const Math::Recti& quad, const AEGraphics::Color& col /*= AEGraphics::Color::Black*/) + { + ASSERT(mImpl); + + } + + void Window::Draw(const AEGraphics::Drawable* texture, const AEGraphics::RenderState& state) + { + ASSERT(mImpl); + + } + + void Window::Draw(const AEGraphics::Drawable* texture, const Math::Recti& quad, const AEGraphics::RenderState& state) + { + ASSERT(mImpl); + + } + + } +} |