-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
50 lines (38 loc) · 1.04 KB
/
main.cpp
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
#include <chrono>
#include <cstdio>
#include <thread>
#include <GLFW/glfw3.h>
inline constexpr int defaultWindowWidth = 640;
inline constexpr int defaultWindowHeight = 480;
int main()
{
if (!glfwInit())
{
std::fprintf(stderr, "Failed to initialize GLFW\n");
return -1;
}
GLFWwindow* const window = glfwCreateWindow(
defaultWindowWidth, defaultWindowHeight, "pt-playground 🛝", nullptr, nullptr);
if (!window)
{
std::fprintf(stderr, "Failed to create GLFW window\n");
glfwTerminate();
return -1;
}
{
glfwMakeContextCurrent(window);
while (!glfwWindowShouldClose(window))
{
glfwPollEvents();
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
{
glfwSetWindowShouldClose(window, GLFW_TRUE);
}
glfwSwapBuffers(window);
std::this_thread::sleep_for(std::chrono::milliseconds(16));
}
}
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}