summaryrefslogtreecommitdiff
path: root/source/modules/asura-core/window/window.cpp
blob: 9dc247d037c3b2f86b45087dcdc0a96189e60ec0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
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);

		}
*/
	}
}