From 2c9463c336ee26eda75213df4bc43d1425aaed07 Mon Sep 17 00:00:00 2001 From: Bliblank Date: Sat, 11 Apr 2026 10:28:14 -0500 Subject: [PATCH] fix: window teardown --- src/app/App.cpp | 9 ++++++--- src/app/Window.cpp | 9 ++++++++- src/app/Window.hpp | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/app/App.cpp b/src/app/App.cpp index 1f6b856..705f48f 100644 --- a/src/app/App.cpp +++ b/src/app/App.cpp @@ -29,13 +29,16 @@ int App::run() { // poll events here // other threads might be able to change quit to true to auto close - while( SDL_PollEvent( &e ) != 0 ) { - if( e.type == SDL_QUIT ) { - // Ctrl + C in console ! + SDL_Event event; + while(SDL_PollEvent(&event)) { // TODO: pass event handling to window + if(event.type == SDL_EVENT_QUIT ) { + quit = true; } } } + // SDL teardown handled in window destructor + return 0; } diff --git a/src/app/Window.cpp b/src/app/Window.cpp index bdcfebf..86e8269 100644 --- a/src/app/Window.cpp +++ b/src/app/Window.cpp @@ -7,10 +7,17 @@ Window::Window() { } +Window::~Window() { + + SDL_DestroyWindow(window_); + SDL_Quit(); + +} + int Window::init() { window_ = SDL_CreateWindow("How to Vulkan", 1280u, 720u, SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE); - return 0; + return (window_ == nullptr); } diff --git a/src/app/Window.hpp b/src/app/Window.hpp index ea5f48e..97b18de 100644 --- a/src/app/Window.hpp +++ b/src/app/Window.hpp @@ -11,7 +11,7 @@ class Window { public: Window(); - ~Window() = default; + ~Window(); private: