Refactor some code
This commit is contained in:
52
openVulkanoCpp/Host/GLFW/PlatformGLFW.cpp
Normal file
52
openVulkanoCpp/Host/GLFW/PlatformGLFW.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
#include "PlatformGLFW.hpp"
|
||||
#include "WindowGLFW.hpp"
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
namespace openVulkanoCpp::GLFW
|
||||
{
|
||||
PlatformGLFW::~PlatformGLFW()
|
||||
{
|
||||
if (IsInitialized())
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
void PlatformGLFW::Init()
|
||||
{
|
||||
if (!glfwInit()) throw PlatformInitFailedException("Failed to initialize glfw");
|
||||
inputProvider.Init();
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
void PlatformGLFW::Tick()
|
||||
{
|
||||
inputProvider.PreTick();
|
||||
glfwPollEvents();
|
||||
inputProvider.Tick();
|
||||
}
|
||||
|
||||
void PlatformGLFW::Close()
|
||||
{
|
||||
for(const IWindow* window : windows)
|
||||
{
|
||||
delete window;
|
||||
}
|
||||
windows.clear();
|
||||
inputProvider.Close();
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
IWindow* PlatformGLFW::MakeWindow()
|
||||
{
|
||||
WindowGLFW* window = new WindowGLFW(inputProvider);
|
||||
windows.push_back(window);
|
||||
return window;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user