Format Code and cleanup.
This commit is contained in:
parent
a0a84f30f8
commit
8b0a7f2622
|
|
@ -93,7 +93,7 @@ using glm::mat2;
|
|||
using glm::mat3;
|
||||
using glm::mat4;
|
||||
|
||||
constexpr const char *PROJECT_NAME = "Aster";
|
||||
constexpr auto *PROJECT_NAME = "Aster";
|
||||
|
||||
struct Version {
|
||||
u32 major;
|
||||
|
|
@ -103,13 +103,8 @@ struct Version {
|
|||
|
||||
constexpr Version VERSION = {
|
||||
.major = 0,
|
||||
.minor = 0,
|
||||
.patch = 1,
|
||||
};
|
||||
|
||||
enum class Error {
|
||||
eUnknown = 1000,
|
||||
eNoDevices = 1001,
|
||||
.minor = 1,
|
||||
.patch = 0,
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
struct GlfwContext {
|
||||
static i32 post_error() noexcept {
|
||||
static const char* error_ = nullptr;
|
||||
static const char *error_ = nullptr;
|
||||
const auto code = glfwGetError(&error_);
|
||||
ERROR("GLFW {}", error_);
|
||||
return code;
|
||||
|
|
@ -18,7 +18,8 @@ struct GlfwContext {
|
|||
inline static u32 count = 0;
|
||||
|
||||
GlfwContext() {
|
||||
if (count++ > 0) return;
|
||||
if (count++ > 0)
|
||||
return;
|
||||
if (glfwInit() == GLFW_FALSE) {
|
||||
CRASH(post_error());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@
|
|||
#include <string>
|
||||
|
||||
#define VULKAN_HPP_ASSERT(expr) DEBUG_IF(!(expr), "Vulkan assert failed")
|
||||
#include <vulkan/vulkan.hpp>
|
||||
#include <vk_mem_alloc.h>
|
||||
#include <vulkan/vulkan.hpp>
|
||||
|
||||
#define CODE_LOC " @ " __FILE__ ":" VULKAN_HPP_STRINGIFY(__LINE__)
|
||||
[[nodiscard]] inline bool failed(const vk::Result _result) {
|
||||
|
|
|
|||
|
|
@ -4,16 +4,12 @@
|
|||
// =============================================
|
||||
|
||||
#include "window.h"
|
||||
#include "logger.h"
|
||||
#include "context.h"
|
||||
#include "glfw_context.h"
|
||||
#include "logger.h"
|
||||
|
||||
Window::Window(const std::string_view& _title, Context* _context, vk::Extent2D _extent, b8 _full_screen)
|
||||
: parent_context{ std::move(_context) }
|
||||
, extent{ _extent }
|
||||
, name{ _title }
|
||||
, full_screen{ _full_screen } {
|
||||
|
||||
Window::Window(const std::string_view &_title, Context *_context, vk::Extent2D _extent, b8 _full_screen) :
|
||||
parent_context{ std::move(_context) }, extent{ _extent }, name{ _title }, full_screen{ _full_screen } {
|
||||
monitor = glfwGetPrimaryMonitor();
|
||||
ERROR_IF(monitor == nullptr, "No monitor found");
|
||||
|
||||
|
|
@ -24,7 +20,8 @@ Window::Window(const std::string_view& _title, Context* _context, vk::Extent2D _
|
|||
glfwWindowHint(GLFW_CENTER_CURSOR, GLFW_TRUE);
|
||||
|
||||
window = glfwCreateWindow(extent.width, extent.height, name.data(), full_screen ? monitor : nullptr, nullptr);
|
||||
ERROR_IF(window == nullptr, "Window creation failed") ELSE_INFO("Window '{}' created with resolution '{}x{}'", name, extent.width, extent.height);
|
||||
ERROR_IF(window == nullptr, "Window creation failed")
|
||||
ELSE_INFO("Window '{}' created with resolution '{}x{}'", name, extent.width, extent.height);
|
||||
if (window == nullptr) {
|
||||
auto code = GlfwContext::post_error();
|
||||
glfwTerminate();
|
||||
|
|
@ -38,20 +35,17 @@ Window::Window(const std::string_view& _title, Context* _context, vk::Extent2D _
|
|||
|
||||
VkSurfaceKHR surface_;
|
||||
auto result = cast<vk::Result>(glfwCreateWindowSurface(cast<VkInstance>(_context->instance), window, nullptr, &surface_));
|
||||
ERROR_IF(failed(result), "Failed to create Surface with {}", to_string(result)) THEN_CRASH(result) ELSE_INFO("Surface Created");
|
||||
ERROR_IF(failed(result), "Failed to create Surface with {}", to_string(result))
|
||||
THEN_CRASH(result) ELSE_INFO("Surface Created");
|
||||
surface = vk::SurfaceKHR(surface_);
|
||||
}
|
||||
|
||||
Window::Window(Window&& _other) noexcept: parent_context{ std::move(_other.parent_context) }
|
||||
, window{ std::exchange(_other.window, nullptr) }
|
||||
, monitor{ _other.monitor }
|
||||
, surface{ std::exchange(_other.surface, nullptr) }
|
||||
, extent{ _other.extent }
|
||||
, name{ std::move(_other.name) }
|
||||
, full_screen{ _other.full_screen } {}
|
||||
Window::Window(Window &&_other) noexcept :
|
||||
parent_context{ std::move(_other.parent_context) }, window{ std::exchange(_other.window, nullptr) }, monitor{ _other.monitor }, surface{ std::exchange(_other.surface, nullptr) }, extent{ _other.extent }, name{ std::move(_other.name) }, full_screen{ _other.full_screen } {}
|
||||
|
||||
Window& Window::operator=(Window&& _other) noexcept {
|
||||
if (this == &_other) return *this;
|
||||
Window &Window::operator=(Window &&_other) noexcept {
|
||||
if (this == &_other)
|
||||
return *this;
|
||||
parent_context = std::move(_other.parent_context);
|
||||
window = _other.window;
|
||||
monitor = _other.monitor;
|
||||
|
|
|
|||
|
|
@ -10,13 +10,12 @@
|
|||
#include "context.h"
|
||||
|
||||
struct Window final {
|
||||
Window(const std::string_view &_title, Context *_context, vk::Extent2D _extent, b8 _full_screen = false);
|
||||
|
||||
Window(const std::string_view& _title, Context* _context, vk::Extent2D _extent, b8 _full_screen = false);
|
||||
|
||||
Window(const Window& _other) = delete;
|
||||
Window(Window&& _other) noexcept;
|
||||
Window& operator=(const Window& _other) = delete;
|
||||
Window& operator=(Window&& _other) noexcept;
|
||||
Window(const Window &_other) = delete;
|
||||
Window(Window &&_other) noexcept;
|
||||
Window &operator=(const Window &_other) = delete;
|
||||
Window &operator=(Window &&_other) noexcept;
|
||||
|
||||
~Window();
|
||||
|
||||
|
|
@ -29,7 +28,7 @@ struct Window final {
|
|||
return !glfwWindowShouldClose(window);
|
||||
}
|
||||
|
||||
void set_window_size(const vk::Extent2D& _extent) noexcept {
|
||||
void set_window_size(const vk::Extent2D &_extent) noexcept {
|
||||
extent = _extent;
|
||||
glfwSetWindowSize(window, extent.width, extent.height);
|
||||
}
|
||||
|
|
@ -39,10 +38,10 @@ struct Window final {
|
|||
}
|
||||
|
||||
// fields
|
||||
Context* parent_context{};
|
||||
Context *parent_context{};
|
||||
|
||||
GLFWwindow* window{ nullptr };
|
||||
GLFWmonitor* monitor{ nullptr };
|
||||
GLFWwindow *window{ nullptr };
|
||||
GLFWmonitor *monitor{ nullptr };
|
||||
vk::SurfaceKHR surface;
|
||||
vk::Extent2D extent;
|
||||
std::string name;
|
||||
|
|
|
|||
Loading…
Reference in New Issue