Files
OpenVulkano/openVulkanoCpp/Host/GLFW/PlatformGLFW.cpp
2020-08-06 20:48:17 +02:00

52 lines
979 B
C++

/*
* 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;
}
}