summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoronelin <oscar@nelin.dk>2025-03-21 13:04:52 +0000
committeronelin <oscar@nelin.dk>2025-03-21 16:28:46 +0000
commit8d0c070971d53eedce1d5f1c4412e08f7f0e8795 (patch)
tree87ba4f6686e58d3c723a68f7f35b7f213c8d37b0
parentfcd22d1fd9d99a73eefa984548adf86189a0060b (diff)
Fix setting wrong window resolution
The desired resolution is not necessary the actual resolution, so we need to poll for the scaling, which can also be different from monitor to monitor. But polling that stuff seems like a job for another day. See glfwSetWindowContentScaleCallback
-rw-r--r--src/core/src/loop.c1
-rw-r--r--src/rendering/src/window.c15
2 files changed, 15 insertions, 1 deletions
diff --git a/src/core/src/loop.c b/src/core/src/loop.c
index dd39db1..49810ef 100644
--- a/src/core/src/loop.c
+++ b/src/core/src/loop.c
@@ -251,6 +251,7 @@ Platform* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight
p->bindings_len = 0;
p->cam = &default_camera;
+
glm_ortho_default(45.f, p->cam->per);
// TODO: Add global bindings
diff --git a/src/rendering/src/window.c b/src/rendering/src/window.c
index b755035..a5e7db6 100644
--- a/src/rendering/src/window.c
+++ b/src/rendering/src/window.c
@@ -162,11 +162,24 @@ Window* init_window_glfw(
ret = (Window*)calloc(1, sizeof(Window));
ret->framework = WINDOW_FRAMEWORK_GLFW;
ret->renderer = WINDOW_RENDERER_NONE;
- glm_ivec2_copy(windowsize, ret->windowsize);
ret->window = window;
/* Last parameter is used for the renderer */
ret->context = NULL;
+ {
+ ivec2 wsize;
+ vec2 wscaling;
+ glfwGetWindowContentScale(window, &wscaling[0], &wscaling[1]);
+ glfwGetWindowSize(window, &wsize[0], &wsize[1]);
+
+ ret->windowsize[0] = (i32)((f32)wsize[0] * wscaling[0]);
+ ret->windowsize[1] = (i32)((f32)wsize[1] * wscaling[1]);
+
+ INFO("WINDOW CONTENT SCALING: %.2f x %.2f", wscaling[0], wscaling[1]);
+ INFO("WINDOW SIZE: %d x %d -> %d x %d", wsize[0], wsize[1], ret->windowsize[0], ret->windowsize[1]);
+ }
+
+
window_poll_events = &glfwPollEvents;
//get_time = &platform_get_time_usec;
get_time = &platform_get_time_usec;