diff --git a/openVulkanoCpp/Host/GLFW/PlatformGLFW.cpp b/openVulkanoCpp/Host/GLFW/PlatformGLFW.cpp index 5a55108..5c5dd40 100644 --- a/openVulkanoCpp/Host/GLFW/PlatformGLFW.cpp +++ b/openVulkanoCpp/Host/GLFW/PlatformGLFW.cpp @@ -10,6 +10,14 @@ namespace openVulkanoCpp::GLFW { + namespace + { + void ErrorCallback(const int error, const char* description) + { + Logger::WINDOW->error("GLFW error (e{0}): {1}", error, description); + } + } + PlatformGLFW::~PlatformGLFW() { if (IsInitialized()) @@ -21,6 +29,7 @@ namespace openVulkanoCpp::GLFW void PlatformGLFW::Init() { if (!glfwInit()) throw PlatformInitFailedException("Failed to initialize glfw"); + glfwSetErrorCallback(ErrorCallback); inputProvider.Init(); initialized = true; } @@ -34,10 +43,6 @@ namespace openVulkanoCpp::GLFW void PlatformGLFW::Close() { - for(const IWindow* window : windows) - { - delete window; - } windows.clear(); inputProvider.Close(); glfwTerminate(); @@ -45,8 +50,9 @@ namespace openVulkanoCpp::GLFW IWindow* PlatformGLFW::MakeWindow() { - WindowGLFW* window = new WindowGLFW(inputProvider); - windows.push_back(window); - return window; + auto window = std::make_unique(inputProvider); + IWindow* windowPtr = window.get(); + windows.emplace_back(std::move(window)); + return windowPtr; } } \ No newline at end of file diff --git a/openVulkanoCpp/Host/GLFW/PlatformGLFW.hpp b/openVulkanoCpp/Host/GLFW/PlatformGLFW.hpp index 0de39bb..3102568 100644 --- a/openVulkanoCpp/Host/GLFW/PlatformGLFW.hpp +++ b/openVulkanoCpp/Host/GLFW/PlatformGLFW.hpp @@ -17,7 +17,7 @@ namespace openVulkanoCpp { class PlatformGLFW final : public IPlatform { - std::vector windows; + std::vector> windows; InputProviderGLFW inputProvider; bool initialized = false; diff --git a/openVulkanoCpp/Host/GLFW/WindowGLFW.cpp b/openVulkanoCpp/Host/GLFW/WindowGLFW.cpp index a11f9f0..7059435 100644 --- a/openVulkanoCpp/Host/GLFW/WindowGLFW.cpp +++ b/openVulkanoCpp/Host/GLFW/WindowGLFW.cpp @@ -61,8 +61,6 @@ namespace openVulkanoCpp::GLFW void WindowGLFW::RegisterCallbacks() const { - glfwSetErrorCallback(ErrorCallback); - glfwSetDropCallback(window, DropCallback); glfwSetFramebufferSizeCallback(window, ResizeCallback); glfwSetWindowFocusCallback(window, FocusCallback); @@ -405,11 +403,6 @@ namespace openVulkanoCpp::GLFW //TODO something useful } - void WindowGLFW::ErrorCallback(const int error, const char* description) - { - Logger::WINDOW->error("GLFW error (e{0}): {1}", error, description); - } - std::vector WindowGLFW::GetVulkanRequiredInstanceExtensions() { std::vector result; diff --git a/openVulkanoCpp/Host/GLFW/WindowGLFW.hpp b/openVulkanoCpp/Host/GLFW/WindowGLFW.hpp index 9927331..ae7488d 100644 --- a/openVulkanoCpp/Host/GLFW/WindowGLFW.hpp +++ b/openVulkanoCpp/Host/GLFW/WindowGLFW.hpp @@ -128,8 +128,6 @@ namespace openVulkanoCpp::GLFW static void DropCallback(GLFWwindow* window, int count, const char** paths); - static void ErrorCallback(int error, const char* description); - public: static std::vector GetVulkanRequiredInstanceExtensions(); };