summaryrefslogtreecommitdiff
path: root/src/renderer/render.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/renderer/render.c')
-rw-r--r--src/renderer/render.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/renderer/render.c b/src/renderer/render.c
new file mode 100644
index 0000000..ce908d6
--- /dev/null
+++ b/src/renderer/render.c
@@ -0,0 +1,42 @@
+#include "render.h"
+
+#include <GLFW/glfw3.h>
+
+#include "log.h"
+#include "render_backend.h"
+
+bool renderer_init(renderer* ren) {
+ INFO("Renderer init");
+
+ // NOTE: all platforms use GLFW at the moment but thats subject to change
+ glfwInit();
+
+ // glfw window creation
+ GLFWwindow* window = glfwCreateWindow(ren->config.scr_width, ren->config.scr_height,
+ ren->config.window_name, NULL, NULL);
+ if (window == NULL) {
+ printf("Failed to create GLFW window\n");
+ glfwTerminate();
+ return false;
+ }
+ ren->window = window;
+
+ glfwMakeContextCurrent(ren->window);
+
+ if (!gfx_backend_init(ren)) {
+ FATAL("Couldnt load graphics api backend");
+ return false;
+ }
+
+ return true;
+}
+
+void render_frame_begin(renderer* ren) {
+ vec3 color = ren->config.clear_colour;
+ clear_screen(color);
+}
+void render_frame_end(renderer* ren) {
+ // present frame
+ glfwSwapBuffers(ren->window);
+ glfwPollEvents();
+} \ No newline at end of file