Skip to content

Commit

Permalink
Resizing window will now properly update camera settings
Browse files Browse the repository at this point in the history
  • Loading branch information
RealDanTheMan committed Jun 29, 2024
1 parent cd89d87 commit 1dbffc0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pyrousel/appwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def __init__(self, width: int = 1280, height: int = 720, enable_gui: bool = True
else:
glfw.make_context_current(self.__win)
glfw.set_key_callback(self.__win, self.OnKeyCallback)
glfw.set_framebuffer_size_callback(self.__win, self.OnWindowResizeCallback)
glfw.swap_interval(int(self.__enable_vsync))

# App user interface (IMGui)
Expand Down Expand Up @@ -245,6 +246,14 @@ def OnKeyCallback(self, window, key, scancode, action, mods) -> None:
if key == glfw.KEY_X and action == glfw.PRESS:
self.draw_gui = not self.draw_gui

def OnWindowResizeCallback(self, window: glfw._GLFWwindow, width: int, height: int) -> None:
self.__width = width
self.__height = height
self.__aspec_ratio = width / height

if self.camera is not None:
self.camera.aspect = self.__aspec_ratio

def Quit(self) -> None:
self.gui.Shutdown()
glfw.terminate()
Expand Down

0 comments on commit 1dbffc0

Please sign in to comment.