summaryrefslogtreecommitdiff
path: root/src/rendering
diff options
context:
space:
mode:
authoronelin <oscar@nelin.dk>2025-03-19 20:57:21 +0000
committeronelin <oscar@nelin.dk>2025-03-19 21:05:41 +0000
commitc9728b92149943f1422283ebf9e8e3eef71a13e1 (patch)
treed2532d19971aff3b3c8b540c9f46c04096e1cacd /src/rendering
parent4af788b4a0d05dbf6816a21aeee2d233fb4e87e6 (diff)
Resize to framesize
Diffstat (limited to 'src/rendering')
-rw-r--r--src/rendering/src/rendering.c3
-rw-r--r--src/rendering/src/window.c8
2 files changed, 10 insertions, 1 deletions
diff --git a/src/rendering/src/rendering.c b/src/rendering/src/rendering.c
index 09af019..81a9e11 100644
--- a/src/rendering/src/rendering.c
+++ b/src/rendering/src/rendering.c
@@ -355,7 +355,8 @@ void r_set_camera(Camera* c) {
void engine_window_resize_pointers(i32* w, i32* h) {
//GLOBAL_PLATFORM->window->game_w = w;
- //GLOBAL_PLATFORM->window->game_h = h;
+ GLOBAL_PLATFORM->window->windowsize[0] = *w;
+ GLOBAL_PLATFORM->window->windowsize[1] = *h;
}
void engine_window_resize_pointers_reset(void) {
diff --git a/src/rendering/src/window.c b/src/rendering/src/window.c
index e3b5524..d1fdbc7 100644
--- a/src/rendering/src/window.c
+++ b/src/rendering/src/window.c
@@ -33,9 +33,16 @@ void glfw_err_callback(int code, const char* description) {
exit(EXIT_FAILURE);
}
+void window_resize_callback(GLFWwindow* window, int width, int height) {
+ const GladGLContext* gl = GLOBAL_PLATFORM->window->context;
+ glfwSwapBuffers(window);
+ gl->Finish();
+}
+
void window_size_callback(GLFWwindow* window, int width, int height) {
const GladGLContext* gl = GLOBAL_PLATFORM->window->context;
Camera* c = GLOBAL_PLATFORM->cam;
+ glfwGetWindowSize(window, &width, &height);
gl->Viewport(0,0, width, height);
GLOBAL_PLATFORM->window->windowsize[0] = width;
GLOBAL_PLATFORM->window->windowsize[1] = height;
@@ -134,6 +141,7 @@ Window* init_window_glfw(
// Setup callbacks
glfwSetFramebufferSizeCallback(window, window_size_callback);
+ glfwSetWindowSizeCallback(window, window_resize_callback);
glfwSetKeyCallback(window, (GLFWkeyfun)key_callback);
// Create the window datastructure