From 07c6b186d266f860686a7c5dcdd3d63b9b282761 Mon Sep 17 00:00:00 2001 From: Samuel Walker Date: Fri, 3 Jan 2025 19:44:13 -0700 Subject: [PATCH] window resizing --- 2dGameProject/Window.cpp | 6 ++++++ 2dGameProject/Window.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/2dGameProject/Window.cpp b/2dGameProject/Window.cpp index 44bcb40..8b98b32 100644 --- a/2dGameProject/Window.cpp +++ b/2dGameProject/Window.cpp @@ -6,6 +6,7 @@ Window::Window(int width, int height, const char* title) { throw ("Failed to create GLFW Window!"); setSize(width, height); setTitle(title); + glfwSetFramebufferSizeCallback(glfw_window, onResize); } @@ -123,4 +124,9 @@ void Window::endRender() { bool Window::isClosing() { return glfwWindowShouldClose(glfw_window); +} + +void Window::onResize(GLFWwindow* window, int width, int height) { + glfwMakeContextCurrent(window); + glViewport(0, 0, width, height); } \ No newline at end of file diff --git a/2dGameProject/Window.h b/2dGameProject/Window.h index 84dc2cb..fdcc775 100644 --- a/2dGameProject/Window.h +++ b/2dGameProject/Window.h @@ -35,5 +35,7 @@ public: void beginRender(); void endRender(); bool isClosing(); +private: + static void onResize(GLFWwindow* window, int width, int height); };