Refactor some code
This commit is contained in:
@@ -1,11 +1,18 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../Base/IPlatform.hpp"
|
||||
#include "WindowGLFW.hpp"
|
||||
#include "InputProviderGLFW.hpp"
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
namespace openVulkanoCpp
|
||||
{
|
||||
class IWindow;
|
||||
|
||||
namespace GLFW
|
||||
{
|
||||
class PlatformGLFW final : public IPlatform
|
||||
@@ -17,47 +24,17 @@ namespace openVulkanoCpp
|
||||
public:
|
||||
PlatformGLFW() = default;
|
||||
|
||||
~PlatformGLFW() override
|
||||
{
|
||||
if (initialized)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
~PlatformGLFW() override;
|
||||
|
||||
bool IsInitialized() const { return initialized; }
|
||||
[[nodiscard]] bool IsInitialized() const { return initialized; }
|
||||
|
||||
void Init() override
|
||||
{
|
||||
if (!glfwInit()) throw PlatformInitFailedException("Failed to initialize glfw");
|
||||
inputProvider.Init();
|
||||
initialized = true;
|
||||
}
|
||||
void Init() override;
|
||||
|
||||
void Tick() override
|
||||
{
|
||||
inputProvider.PreTick();
|
||||
glfwPollEvents();
|
||||
inputProvider.Tick();
|
||||
}
|
||||
void Tick() override;
|
||||
|
||||
void Close() override
|
||||
{
|
||||
for(const IWindow* window : windows)
|
||||
{
|
||||
delete window;
|
||||
}
|
||||
windows.clear();
|
||||
inputProvider.Close();
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
IWindow* MakeWindow() override
|
||||
{
|
||||
WindowGLFW* window = new WindowGLFW(inputProvider);
|
||||
windows.push_back(window);
|
||||
return window;
|
||||
}
|
||||
void Close() override;
|
||||
|
||||
IWindow* MakeWindow() override;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user