summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMel <mel@rnrd.eu>2026-09-03 05:01:46 +0200
committerMel <mel@rnrd.eu>2026-09-03 05:01:46 +0200
commit1952628825ee526e4ae32170266f8eaa323a0e16 (patch)
tree55cf4ff13a2d647723f5b7ca0f60a2e8562b61da
parent3af28453019a98b26f5c08ed49a6df633b36addb (diff)
downloadmeowcraft-1952628825ee526e4ae32170266f8eaa323a0e16.tar.zst
meowcraft-1952628825ee526e4ae32170266f8eaa323a0e16.zip
Support larger framebuffers of HiDPI displays
Signed-off-by: Mel <mel@rnrd.eu>
-rw-r--r--src/GFX/Window.cpp4
-rw-r--r--src/GFX/Window.hpp1
-rw-r--r--src/Render.cpp4
3 files changed, 8 insertions, 1 deletions
diff --git a/src/GFX/Window.cpp b/src/GFX/Window.cpp
index 75e7613..7d0f5b3 100644
--- a/src/GFX/Window.cpp
+++ b/src/GFX/Window.cpp
@@ -58,6 +58,10 @@ void Window::on_size_change(void (callback)(GLFWwindow*, I32, I32)) const {
glfwSetFramebufferSizeCallback(m_window, callback);
}
+void Window::framebuffer_size(I32& width, I32& height) const {
+ glfwGetFramebufferSize(m_window, &width, &height);
+}
+
void Window::attach() const {
glfwMakeContextCurrent(m_window);
}
diff --git a/src/GFX/Window.hpp b/src/GFX/Window.hpp
index 86920b5..99824b1 100644
--- a/src/GFX/Window.hpp
+++ b/src/GFX/Window.hpp
@@ -15,6 +15,7 @@ public:
PURE GLFWwindow* get() const;
void on_size_change(void (* callback)(GLFWwindow*, I32, I32)) const;
+ void framebuffer_size(I32& width, I32& height) const;
void attach() const;
void detach() const;
diff --git a/src/Render.cpp b/src/Render.cpp
index 1089ad4..5293e9c 100644
--- a/src/Render.cpp
+++ b/src/Render.cpp
@@ -21,7 +21,9 @@ void Render::run() {
m_resources.initialize();
- glViewport(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT);
+ I32 framebuffer_width, framebuffer_height;
+ m_window.framebuffer_size(framebuffer_width, framebuffer_height);
+ glViewport(0, 0, framebuffer_width, framebuffer_height);
m_window.on_size_change([](GLFWwindow* _, I32 w, I32 h) {
glViewport(0, 0, w, h);
});