blob: 8f1c6ea8f4b26018587de4ccfe928c6018fac049 (
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
|
#include "Window.h"
#include <cstdint>
namespace Donut
{
static bool s_GLFWInitialized = false;
static uint32_t s_GLFWWindowCount = 0;
Window::Window(const std::string& title, int width, int height)
: m_Title(title), m_Width(width), m_Height(height)
{
if (!s_GLFWInitialized)
{
glfwInit();
s_GLFWInitialized = true;
}
m_Window = glfwCreateWindow(width, height, title.c_str(), nullptr, nullptr);
glfwMakeContextCurrent(m_Window);
s_GLFWWindowCount++;
}
Window::~Window()
{
glfwDestroyWindow(m_Window);
s_GLFWWindowCount--;
if (s_GLFWWindowCount == 0)
{
glfwTerminate();
s_GLFWInitialized = false;
}
}
void Window::OnUpdate() const
{
glfwPollEvents();
glfwSwapBuffers(m_Window);
}
bool Window::ShouldClose() const
{
return glfwWindowShouldClose(m_Window);
}
}
|