aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2024-05-15 14:23:20 +0200
committerlonkaars <loek@pipeframe.xyz>2024-05-15 14:23:20 +0200
commit0a5c176456b7afe024910183392d59116c37088e (patch)
tree4ac1f5241f7b015e0aba7b00e79333a3d88a918c /main.c
parent3ca23ebf8123cf909a057ba6fe833d64aedcb957 (diff)
more hello world (pink window)
Diffstat (limited to 'main.c')
-rw-r--r--main.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/main.c b/main.c
index be899de..3beddeb 100644
--- a/main.c
+++ b/main.c
@@ -1,5 +1,12 @@
+#include <stdlib.h>
#include <GLFW/glfw3.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();
@@ -8,6 +15,26 @@ int main(int argc, char** argv) {
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
- return 0;
+ 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)) {
+ glClearColor(1.f, 0.f, 1.f, 1.0f);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glfwSwapBuffers(window);
+ }
+
+ glfwTerminate();
+ return EXIT_SUCCESS;
}