Move GLFW error handling into PlatformGLFW
This commit is contained in:
@@ -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<WindowGLFW>(inputProvider);
|
||||
IWindow* windowPtr = window.get();
|
||||
windows.emplace_back(std::move(window));
|
||||
return windowPtr;
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ namespace openVulkanoCpp
|
||||
{
|
||||
class PlatformGLFW final : public IPlatform
|
||||
{
|
||||
std::vector<WindowGLFW*> windows;
|
||||
std::vector<std::unique_ptr<IWindow>> windows;
|
||||
InputProviderGLFW inputProvider;
|
||||
bool initialized = false;
|
||||
|
||||
|
||||
@@ -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<std::string> WindowGLFW::GetVulkanRequiredInstanceExtensions()
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
|
||||
@@ -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<std::string> GetVulkanRequiredInstanceExtensions();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user