aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2024-05-15 15:05:07 +0200
committerlonkaars <loek@pipeframe.xyz>2024-05-15 15:05:07 +0200
commit83ed40fd01120e1b46dba5d2bac895862731196d (patch)
treea2d4e78ec97e337d8808e234d70aaccc95c53bb4
parent0a5c176456b7afe024910183392d59116c37088e (diff)
separate draw loop into file
-rw-r--r--draw.c6
-rw-r--r--draw.h7
-rw-r--r--main.c6
-rw-r--r--makefile1
4 files changed, 17 insertions, 3 deletions
diff --git a/draw.c b/draw.c
new file mode 100644
index 0000000..0dfa09c
--- /dev/null
+++ b/draw.c
@@ -0,0 +1,6 @@
+#include "draw.h"
+
+void draw(GLFWwindow* window) {
+ glClearColor(1.f, 0.f, 1.f, 1.0f);
+ glClear(GL_COLOR_BUFFER_BIT);
+}
diff --git a/draw.h b/draw.h
new file mode 100644
index 0000000..617569b
--- /dev/null
+++ b/draw.h
@@ -0,0 +1,7 @@
+#pragma once
+
+#include <GLFW/glfw3.h>
+
+/** @brief draw loop iteration, called once for every frame */
+void draw(GLFWwindow*);
+
diff --git a/main.c b/main.c
index 3beddeb..ab5f97b 100644
--- a/main.c
+++ b/main.c
@@ -1,6 +1,7 @@
#include <stdlib.h>
#include <GLFW/glfw3.h>
+#include "draw.h"
#include "die.h"
void resize_handler(GLFWwindow* window, int width, int height) {
@@ -28,10 +29,9 @@ int main(int argc, char** argv) {
resize_handler(window, width, height);
while (!glfwWindowShouldClose(window)) {
- glClearColor(1.f, 0.f, 1.f, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT);
-
+ draw(window);
glfwSwapBuffers(window);
+ glfwPollEvents();
}
glfwTerminate();
diff --git a/makefile b/makefile
index 684dab0..49551f1 100644
--- a/makefile
+++ b/makefile
@@ -7,6 +7,7 @@ all: main FORCE
main: main.o
main: die.o
+main: draw.o
clean: FORCE
git clean -fxdi