Split IWindow a bit

This commit is contained in:
2020-10-24 23:02:01 +02:00
parent 30dd4f255c
commit ae76fa59e9
8 changed files with 55 additions and 32 deletions

View File

@@ -13,7 +13,7 @@ namespace openVulkanoCpp
class BaseWindow : virtual public IWindow class BaseWindow : virtual public IWindow
{ {
protected: protected:
const int windowId; const uint32_t windowId;
WindowConfiguration windowConfig; WindowConfiguration windowConfig;
public: public:
@@ -121,7 +121,7 @@ namespace openVulkanoCpp
return nullptr; return nullptr;
} }
int GetWindowId() const override [[nodiscard]] uint32_t GetWindowId() const override
{ {
return windowId; return windowId;
} }

View File

@@ -0,0 +1,21 @@
/*
* 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 "IWindow.hpp"
namespace openVulkanoCpp
{
class IOpenGlWindow : virtual public IWindow
{
public:
~IOpenGlWindow() override = default;
virtual void MakeCurrentThread() = 0;
virtual void Present() const = 0;
};
}

View File

@@ -0,0 +1,23 @@
/*
* 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 "IWindow.hpp"
#include <vector>
#include <vulkan/vulkan.hpp>
namespace openVulkanoCpp
{
class IVulkanWindow : virtual public IWindow
{
public:
~IVulkanWindow() override = default;
virtual vk::SurfaceKHR CreateSurface(const vk::Instance& instance, const vk::AllocationCallbacks* pAllocator = nullptr) = 0;
virtual std::vector<std::string> GetRequiredInstanceExtensions() = 0;
};
}

View File

@@ -6,12 +6,11 @@
#pragma once #pragma once
#include <string>
#include <stdexcept>
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <vulkan/vulkan.hpp>
#include "../PlatformEnums.hpp" #include "../PlatformEnums.hpp"
#include "../ICloseable.hpp" #include "../ICloseable.hpp"
#include <string>
#include <stdexcept>
namespace openVulkanoCpp namespace openVulkanoCpp
{ {
@@ -82,34 +81,16 @@ namespace openVulkanoCpp
virtual IVulkanWindow* GetVulkanWindow() = 0; virtual IVulkanWindow* GetVulkanWindow() = 0;
virtual IOpenGlWindow* GetOpenGlWindow() = 0; virtual IOpenGlWindow* GetOpenGlWindow() = 0;
virtual int GetWindowId() const = 0; [[nodiscard]] virtual uint32_t GetWindowId() const = 0;
protected: protected:
static int CreateWindowId() static uint32_t CreateWindowId()
{ {
static int id = 0; static uint32_t id = 0;
return id++; return id++;
} }
}; };
class IVulkanWindow : virtual public IWindow
{
public:
virtual ~IVulkanWindow() = default;
virtual vk::SurfaceKHR CreateSurface(const vk::Instance& instance, const vk::AllocationCallbacks* pAllocator = nullptr) = 0;
virtual std::vector<std::string> GetRequiredInstanceExtensions() = 0;
};
class IOpenGlWindow : virtual public IWindow
{
public:
virtual ~IOpenGlWindow() = default;
virtual void MakeCurrentThread() = 0;
virtual void Present() const = 0;
};
class IWindowHandler class IWindowHandler
{ {
public: public:

View File

@@ -10,7 +10,6 @@
#include <string> #include <string>
#include <set> #include <set>
#include <algorithm> #include <algorithm>
#include <glm/vec3.hpp>
namespace openVulkanoCpp namespace openVulkanoCpp
{ {
@@ -56,11 +55,6 @@ namespace openVulkanoCpp
return static_cast<typename std::underlying_type<Enumeration>::type>(value); return static_cast<typename std::underlying_type<Enumeration>::type>(value);
} }
static inline bool MatchesAnyElementWise(const glm::vec3& a, const glm::vec3& b)
{
return a.x == b.x || a.y == b.y || a.z == b.z;
}
static inline size_t Align(size_t size, size_t alignment) static inline size_t Align(size_t size, size_t alignment)
{ {
return (size + alignment - 1) & ~(alignment - 1); return (size + alignment - 1) & ~(alignment - 1);

View File

@@ -7,6 +7,8 @@
#pragma once #pragma once
#include "../../Base/UI/BaseWindow.hpp" #include "../../Base/UI/BaseWindow.hpp"
#include "../../Base/UI/IVulkanWindow.hpp"
#include "../../Base/UI/IOpenGlWindow.hpp"
#include "../../Base/IPlatform.hpp" #include "../../Base/IPlatform.hpp"
#include "InputProviderGLFW.hpp" #include "InputProviderGLFW.hpp"

View File

@@ -10,6 +10,7 @@
#include "../Base/IGraphicsApp.hpp" #include "../Base/IGraphicsApp.hpp"
#include "../Base/IGraphicsAppManager.hpp" #include "../Base/IGraphicsAppManager.hpp"
#include "../Base/EngineConstants.hpp" #include "../Base/EngineConstants.hpp"
#include "../Base/UI/IVulkanWindow.hpp"
#include "Debuging/ValidationLayer.hpp" #include "Debuging/ValidationLayer.hpp"
namespace openVulkanoCpp::Vulkan namespace openVulkanoCpp::Vulkan

View File

@@ -7,6 +7,7 @@
#include "SwapChain.hpp" #include "SwapChain.hpp"
#include "../Base/Logger.hpp" #include "../Base/Logger.hpp"
#include "../Base/Utils.hpp" #include "../Base/Utils.hpp"
#include "../Base/UI/IVulkanWindow.hpp"
#include <algorithm> #include <algorithm>
namespace openVulkanoCpp::Vulkan namespace openVulkanoCpp::Vulkan