blob: 91e1b23d2fcdb00470a3757cb6fd4aa017ae58cd (
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
|
#include <iostream>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include "Window.hpp"
#define APP_NAME "Meowcraft"
#define WINDOW_WIDTH 1000
#define WINDOW_HEIGHT 800
void run();
void setup_gl();
int main() {
glfwInit();
try {
run();
} catch (std::runtime_error& error) {
std::cout << "An error occurred: " << error.what() << std::endl;
glfwTerminate();
return 1;
}
glfwTerminate();
return 0;
}
void run() {
MC::Window window(APP_NAME, WINDOW_WIDTH, WINDOW_HEIGHT);
setup_gl();
glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
while (!window.should_close()) {
window.start_frame();
if (window.key(GLFW_KEY_ESCAPE, GLFW_PRESS)) {
window.close();
}
}
}
void setup_gl() {
GLenum error;
if ((error = glewInit()) != GLEW_OK) {
std::string error_string = std::string(reinterpret_cast<const char*>(glewGetErrorString(error)));
throw std::runtime_error("Failed to load GL functions: " + error_string);
}
}
|