From 1b9b0d85e692dcea88bd9d28d04b170d8c3b9d14 Mon Sep 17 00:00:00 2001 From: Archie Hilton Date: Tue, 14 May 2024 21:13:05 +0100 Subject: [PATCH] Add framebuffer resize callback --- src/main.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main.cc b/src/main.cc index e3d87bc..14cb350 100644 --- a/src/main.cc +++ b/src/main.cc @@ -56,6 +56,14 @@ GLuint g_program_id = 0; static GLuint translate_unif; static GLuint rotate_unif; +void framebuffer_size_callback(GLFWwindow* window, int width, int height) +{ + // make sure the viewport matches the new window dimensions; note that width and + // height will be significantly larger than specified on retina displays. + glViewport(0, 0, width, height); + // Re-render the scene because the current frame was drawn for the old resolution +} + static void init_shaders() { dbg_log("Initialising shaders"); @@ -134,6 +142,7 @@ int main() { // Set up the key handler glfwSetKeyCallback(w, key_callback); + glfwSetFramebufferSizeCallback(w, framebuffer_size_callback); init_opengl();