hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/src/core/application.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/application.c')
-rw-r--r--src/core/application.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/core/application.c b/src/core/application.c
new file mode 100644
index 0000000..f859434
--- /dev/null
+++ b/src/core/application.c
@@ -0,0 +1,63 @@
+#include "application.h"
+
+#include <stdlib.h>
+
+struct Application* application_create(void)
+{
+ // legit who gives a fuck about validation bro
+ glfwInit();
+
+ struct Application* application = (struct Application*) malloc(sizeof(struct Application));
+
+ application->game_window = glfwCreateWindow(GAME_WINDOW_WIDTH, GAME_WINDOW_HEIGHT,
+ "I can't see or hear shit", NULL, NULL);
+ application->debug_window = glfwCreateWindow(DEBUG_WINDOW_WIDTH, DEBUG_WINDOW_HEIGHT,
+ "Debug", NULL, application->game_window);
+
+ return application;
+}
+
+void application_render_game(struct Application* application)
+{
+ glfwMakeContextCurrent(application->game_window);
+
+ glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glfwSwapBuffers(application->game_window);
+}
+
+void application_render_debug(struct Application* application)
+{
+ glfwMakeContextCurrent(application->debug_window);
+
+ glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glfwSwapBuffers(application->debug_window);
+}
+
+void application_update(struct Application* application)
+{
+ glfwPollEvents();
+}
+
+void application_run(struct Application* application)
+{
+ while (!glfwWindowShouldClose(application->game_window) &&
+ !glfwWindowShouldClose(application->debug_window))
+ {
+ application_render_game(application);
+ application_render_debug(application);
+ application_update(application);
+ }
+}
+
+void application_destroy(struct Application* application)
+{
+ glfwDestroyWindow(application->game_window);
+ glfwDestroyWindow(application->debug_window);
+ glfwTerminate();
+
+ free(application);
+}