Add printable Enum

This commit is contained in:
Thraix
2023-05-01 18:23:22 +02:00
parent ca7286807a
commit ad69293faa
17 changed files with 122 additions and 76 deletions
+1 -1
View File
@@ -173,7 +173,7 @@ namespace Copium
void Application::InitializeCommandBuffer()
{
commandBuffer = std::make_unique<CommandBuffer>(CommandBuffer::Type::Dynamic);
commandBuffer = std::make_unique<CommandBuffer>(CommandBufferType::Dynamic);
}
void Application::RecordCommandBuffer()
+1 -1
View File
@@ -16,7 +16,7 @@ namespace Copium
void Vulkan::Initialize()
{
instance = std::make_unique<Instance>("Copium Engine");
window = std::make_unique<Window>("Copium Engine", 1920, 1080, Window::Mode::Windowed);
window = std::make_unique<Window>("Copium Engine", 1920, 1080, WindowMode::Windowed);
device = std::make_unique<Device>();
swapChain = std::make_unique<SwapChain>();
+6 -6
View File
@@ -13,7 +13,7 @@
namespace Copium
{
Window::Window(const std::string& windowName, int width, int height, Mode mode)
Window::Window(const std::string& windowName, int width, int height, WindowMode mode)
{
InitializeWindow(windowName, width, height, mode);
InitializeSurface();
@@ -35,20 +35,20 @@ namespace Copium
return window;
}
void Window::InitializeWindow(const std::string& windowName, int width, int height, Mode mode)
void Window::InitializeWindow(const std::string& windowName, int width, int height, WindowMode mode)
{
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
switch (mode)
{
case Mode::Fullscreen:
case WindowMode::Fullscreen:
{
GLFWmonitor* monitor = glfwGetPrimaryMonitor();
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
window = glfwCreateWindow(mode->width, mode->height, windowName.c_str(), glfwGetPrimaryMonitor(), nullptr);
break;
}
case Mode::BorderlessWindowed:
case WindowMode::BorderlessWindowed:
{
GLFWmonitor* monitor = glfwGetPrimaryMonitor();
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
@@ -56,13 +56,13 @@ namespace Copium
glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate);
break;
}
case Mode::Windowed:
case WindowMode::Windowed:
{
window = glfwCreateWindow(width, height, windowName.c_str(), nullptr, nullptr);
break;
}
default:
CP_ABORT("Unreachable switch case");
CP_ABORT("Unreachable switch case: %s", ToString(mode).c_str());
}
CP_ASSERT(window, "Failed to initialize glfw window");
+6 -7
View File
@@ -1,32 +1,31 @@
#pragma once
#include "copium/util/Common.h"
#include "copium/util/Enum.h"
#include <GLFW/glfw3.h>
#define CP_WINDOW_MODE_ENUMS Fullscreen, BorderlessWindowed, Windowed
CP_ENUM_CREATOR(Copium, WindowMode, CP_WINDOW_MODE_ENUMS);
namespace Copium
{
class Window final
{
CP_DELETE_COPY_AND_MOVE_CTOR(Window);
public:
enum class Mode
{
Fullscreen, BorderlessWindowed, Windowed
};
private:
GLFWwindow* window;
VkSurfaceKHR surface;
public:
Window(const std::string& windowName, int width, int height, Mode mode);
Window(const std::string& windowName, int width, int height, WindowMode mode);
~Window();
VkSurfaceKHR GetSurface() const;
GLFWwindow* GetWindow();
private:
void InitializeWindow(const std::string& windowName, int width, int height, Mode mode);
void InitializeWindow(const std::string& windowName, int width, int height, WindowMode mode);
void InitializeSurface();
static void FramebufferResizeCallback(GLFWwindow* glfwWindow, int width, int height);