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
|
#include <stdlib.h>
#include <GLFW/glfw3.h>
#include "draw.h"
#include "die.h"
void resize_handler(GLFWwindow* window, int width, int height) {
glViewport(0, 0, width, height);
}
int main(int argc, char** argv) {
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
int width = 800, height = 600;
GLFWwindow* window = glfwCreateWindow(width, height, "vis", NULL, NULL);
if (window == NULL) {
glfwTerminate();
die("error: could not create window\n");
}
glfwMakeContextCurrent(window);
glfwSetFramebufferSizeCallback(window, resize_handler);
resize_handler(window, width, height);
while (!glfwWindowShouldClose(window)) {
draw(window);
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
return EXIT_SUCCESS;
}
|