-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindow_system.cpp
More file actions
41 lines (37 loc) · 955 Bytes
/
Copy pathwindow_system.cpp
File metadata and controls
41 lines (37 loc) · 955 Bytes
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
//
// Created by arrayJY on 2022/12/6.
//
#include "window_system.h"
#include <GLFW/glfw3.h>
#include <stdexcept>
namespace Sparrow {
WindowSystem::~WindowSystem() {
glfwDestroyWindow(window);
glfwTerminate();
}
void WindowSystem::initialize(const WindowSystemInitInfo& initInfo) {
if (!glfwInit()) {
throw std::runtime_error("GLFW init failed.");
}
width = initInfo.width, height = initInfo.height;
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
window = glfwCreateWindow(width, height, "Sparrow Engine", nullptr, nullptr);
if (!window) {
throw std::runtime_error("GLFW create window failed.");
}
}
void WindowSystem::pollEvents() const {
glfwPollEvents();
}
bool WindowSystem::shouldClose() const {
return glfwWindowShouldClose(window);
}
GLFWwindow* WindowSystem::getWindow() const {
return window;
}
/*
auto WindowSystem::getWindowSize() const {
return std::make_tuple(width, height);
}
*/
} // namespace Sparrow