summaryrefslogtreecommitdiff
path: root/src/renderer/render.c
blob: 4e9ad89c21aa88d7efccedc79a126e45a43ed00d (plain)
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
41
42
#include "render.h"

#include <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();
}