diff options
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..adba7c9 --- /dev/null +++ b/source/modules/asura-core/Window/Window.cpp @@ -0,0 +1,104 @@ +#include <asura-utils/Exceptions/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); + + } +*/ + } +} |