diff --git a/SDLU/graphics/RenderWindow.cpp b/SDLU/graphics/RenderWindow.cpp index 4f4972b..4bdcbe7 100644 --- a/SDLU/graphics/RenderWindow.cpp +++ b/SDLU/graphics/RenderWindow.cpp @@ -24,4 +24,17 @@ namespace sdlu { // Empty } + + void RenderWindow::OnCreate() + { + } + + bool RenderWindow::OnResize() + { + return false; + } + + void RenderWindow::OnClose() + { + } } \ No newline at end of file diff --git a/SDLU/graphics/RenderWindow.hpp b/SDLU/graphics/RenderWindow.hpp index a7dc99b..2de90f5 100644 --- a/SDLU/graphics/RenderWindow.hpp +++ b/SDLU/graphics/RenderWindow.hpp @@ -43,11 +43,30 @@ namespace sdlu * @param[in] title The title of the create window */ RenderWindow(Vector2u dimension, const std::string& title, - Uint32 windowFlags); + Uint32 windowFlags = SDL_WINDOW_SHOWN); RenderWindow(const RenderWindow& other) = delete; RenderWindow(const RenderWindow&& other) = delete; virtual ~RenderWindow(); + + protected: + /** + * @brief Function called after Window creation + */ + virtual void OnCreate(); + + /** + * @brief Function called after resize event + * + * @return True if the resize event should not be returned via + * PollEvent() + */ + virtual bool OnResize(); + + /** + * @brief Function called after closing the window + */ + virtual void OnClose(); }; } \ No newline at end of file diff --git a/SDLU/structures/Window.cpp b/SDLU/structures/Window.cpp index aea07ce..15c2e8b 100644 --- a/SDLU/structures/Window.cpp +++ b/SDLU/structures/Window.cpp @@ -237,4 +237,17 @@ namespace sdlu size.x, size.y, 32, 8 * size.x, SDL_PIXELFORMAT_RGBA32); this->SetMouseCursor(surface, clickspot); } + + void Window::OnCreate() + { + } + + bool Window::OnResize() + { + return false; + } + + void Window::OnClose() + { + } } \ No newline at end of file diff --git a/SDLU_Example/header.hpp b/SDLU_Example/header.hpp index a640b05..e9fa40b 100644 --- a/SDLU_Example/header.hpp +++ b/SDLU_Example/header.hpp @@ -13,20 +13,21 @@ public: { // Empty } -}; -void sdlu::Window::OnCreate() -{ - std::cout << "Window was Created!" << std::endl; -} +private: + virtual void OnCreate() + { + std::cout << "MyWindow created!" << std::endl; + } -bool sdlu::Window::OnResize() -{ - std::cout << "Window was Resized!" << std::endl; - return true; -} + virtual bool OnResize() + { + std::cout << "MyWindow resized!" << std::endl; + return true; + } -void sdlu::Window::OnClose() -{ - std::cout << "Window was Closed!" << std::endl; -} \ No newline at end of file + virtual void OnClose() + { + std::cout << "MyWindow closed!" << std::endl; + } +}; \ No newline at end of file diff --git a/SDLU_Example/main.cpp b/SDLU_Example/main.cpp index b9036ef..e23b71a 100644 --- a/SDLU_Example/main.cpp +++ b/SDLU_Example/main.cpp @@ -29,7 +29,6 @@ int main(int argc, char** argv) window.SetMaxFramerate(144); SDL_Event event; - float t = 0.f; std::string title = ""; while (window.IsOpen()) @@ -55,7 +54,6 @@ int main(int argc, char** argv) 100, 100)); window.Display(); - t += 0.08; diff = std::chrono::duration_cast (std::chrono::steady_clock::now() - start).count();