summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/camera.c3
-rw-r--r--src/config.h2
-rw-r--r--src/window.c3
3 files changed, 6 insertions, 2 deletions
diff --git a/src/camera.c b/src/camera.c
index cbea1ff..c15ff16 100644
--- a/src/camera.c
+++ b/src/camera.c
@@ -1,6 +1,7 @@
#include "camera.h"
#include "cglm/cam.h"
#include "cglm/io.h"
+#include "config.h"
#include "cglm/mat4.h"
#include "cglm/util.h"
#include "cglm/vec3.h"
@@ -31,7 +32,7 @@ void camera_update(struct camera* camera, struct shader* shader) {
// glm_lookat(camera, cam_pivot, axis_y, blk->view);
// glm_rotate_at(blk->view, cam_pivot, angle, axis_y);
// Projection (perspective) matrix
- glm_perspective(camera->fov, 800.0f / 600.0f, 0.1f, -10.0f, camera->perspective);
+ glm_perspective(camera->fov, SCREEN_WIDTH / SCREEN_HEIGHT, 0.1f, -10.0f, camera->perspective);
set_uniform_mat4("view", shader, camera->view);
set_uniform_mat4("perspective", shader, camera->perspective);
// fprintf(stderr, "==== Block View ====\n");
diff --git a/src/config.h b/src/config.h
new file mode 100644
index 0000000..8fc4348
--- /dev/null
+++ b/src/config.h
@@ -0,0 +1,2 @@
+#define SCREEN_WIDTH 800.0f
+#define SCREEN_HEIGHT 600.0f
diff --git a/src/window.c b/src/window.c
index e3faff7..894a42b 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1,11 +1,12 @@
#include "window.h"
#include "glad/glad.h"
+#include "config.h"
#include <stdio.h>
int window_init(struct window* window) {
SDL_Init(SDL_INIT_VIDEO);
// This will call SDL_GL_LoadLibrary so you don't need glad to do anything
- window->window = SDL_CreateWindow("Junkcraft", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_OPENGL);
+ window->window = SDL_CreateWindow("Junkcraft", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL);
SDL_GLContext* ctx = SDL_GL_CreateContext(window->window);
// Let GLAD use the SDL GetProcAddress loader instead of using its own