Move GLFW error handling into PlatformGLFW
This commit is contained in:
@@ -10,6 +10,14 @@
|
|||||||
|
|
||||||
namespace openVulkanoCpp::GLFW
|
namespace openVulkanoCpp::GLFW
|
||||||
{
|
{
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
void ErrorCallback(const int error, const char* description)
|
||||||
|
{
|
||||||
|
Logger::WINDOW->error("GLFW error (e{0}): {1}", error, description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PlatformGLFW::~PlatformGLFW()
|
PlatformGLFW::~PlatformGLFW()
|
||||||
{
|
{
|
||||||
if (IsInitialized())
|
if (IsInitialized())
|
||||||
@@ -21,6 +29,7 @@ namespace openVulkanoCpp::GLFW
|
|||||||
void PlatformGLFW::Init()
|
void PlatformGLFW::Init()
|
||||||
{
|
{
|
||||||
if (!glfwInit()) throw PlatformInitFailedException("Failed to initialize glfw");
|
if (!glfwInit()) throw PlatformInitFailedException("Failed to initialize glfw");
|
||||||
|
glfwSetErrorCallback(ErrorCallback);
|
||||||
inputProvider.Init();
|
inputProvider.Init();
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
@@ -34,10 +43,6 @@ namespace openVulkanoCpp::GLFW
|
|||||||
|
|
||||||
void PlatformGLFW::Close()
|
void PlatformGLFW::Close()
|
||||||
{
|
{
|
||||||
for(const IWindow* window : windows)
|
|
||||||
{
|
|
||||||
delete window;
|
|
||||||
}
|
|
||||||
windows.clear();
|
windows.clear();
|
||||||
inputProvider.Close();
|
inputProvider.Close();
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
@@ -45,8 +50,9 @@ namespace openVulkanoCpp::GLFW
|
|||||||
|
|
||||||
IWindow* PlatformGLFW::MakeWindow()
|
IWindow* PlatformGLFW::MakeWindow()
|
||||||
{
|
{
|
||||||
WindowGLFW* window = new WindowGLFW(inputProvider);
|
auto window = std::make_unique<WindowGLFW>(inputProvider);
|
||||||
windows.push_back(window);
|
IWindow* windowPtr = window.get();
|
||||||
return window;
|
windows.emplace_back(std::move(window));
|
||||||
|
return windowPtr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@ namespace openVulkanoCpp
|
|||||||
{
|
{
|
||||||
class PlatformGLFW final : public IPlatform
|
class PlatformGLFW final : public IPlatform
|
||||||
{
|
{
|
||||||
std::vector<WindowGLFW*> windows;
|
std::vector<std::unique_ptr<IWindow>> windows;
|
||||||
InputProviderGLFW inputProvider;
|
InputProviderGLFW inputProvider;
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
|
|
||||||
|
|||||||
@@ -61,8 +61,6 @@ namespace openVulkanoCpp::GLFW
|
|||||||
|
|
||||||
void WindowGLFW::RegisterCallbacks() const
|
void WindowGLFW::RegisterCallbacks() const
|
||||||
{
|
{
|
||||||
glfwSetErrorCallback(ErrorCallback);
|
|
||||||
|
|
||||||
glfwSetDropCallback(window, DropCallback);
|
glfwSetDropCallback(window, DropCallback);
|
||||||
glfwSetFramebufferSizeCallback(window, ResizeCallback);
|
glfwSetFramebufferSizeCallback(window, ResizeCallback);
|
||||||
glfwSetWindowFocusCallback(window, FocusCallback);
|
glfwSetWindowFocusCallback(window, FocusCallback);
|
||||||
@@ -405,11 +403,6 @@ namespace openVulkanoCpp::GLFW
|
|||||||
//TODO something useful
|
//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> WindowGLFW::GetVulkanRequiredInstanceExtensions()
|
||||||
{
|
{
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
|
|||||||
@@ -128,8 +128,6 @@ namespace openVulkanoCpp::GLFW
|
|||||||
|
|
||||||
static void DropCallback(GLFWwindow* window, int count, const char** paths);
|
static void DropCallback(GLFWwindow* window, int count, const char** paths);
|
||||||
|
|
||||||
static void ErrorCallback(int error, const char* description);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static std::vector<std::string> GetVulkanRequiredInstanceExtensions();
|
static std::vector<std::string> GetVulkanRequiredInstanceExtensions();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user