File hierarchy cleanup.
This commit is contained in:
parent
5744e7a13c
commit
ccb0aa5fbe
|
|
@ -19,4 +19,4 @@ endif ()
|
||||||
include(add_shader.cmake)
|
include(add_shader.cmake)
|
||||||
|
|
||||||
add_subdirectory("aster")
|
add_subdirectory("aster")
|
||||||
add_subdirectory("triangle")
|
add_subdirectory("samples")
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,16 @@ Context::Context(const cstr appName, const Version version, bool enableValidatio
|
||||||
{
|
{
|
||||||
INFO_IF(enableValidation, "Validation Layers enabled");
|
INFO_IF(enableValidation, "Validation Layers enabled");
|
||||||
|
|
||||||
|
if (!glfwInit())
|
||||||
|
{
|
||||||
|
const char *error = nullptr;
|
||||||
|
const auto code = glfwGetError(&error);
|
||||||
|
ERROR("GLFW Init failed. Cause: ({}) {}", code, error)
|
||||||
|
THEN_ABORT(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO Get/Check API Version
|
||||||
|
|
||||||
// Creating Instance
|
// Creating Instance
|
||||||
const vk::ApplicationInfo appInfo = {
|
const vk::ApplicationInfo appInfo = {
|
||||||
.pApplicationName = appName,
|
.pApplicationName = appName,
|
||||||
|
|
@ -109,4 +119,6 @@ Context::~Context()
|
||||||
}
|
}
|
||||||
m_Instance.destroy(nullptr);
|
m_Instance.destroy(nullptr);
|
||||||
DEBUG("Instance destroyed");
|
DEBUG("Instance destroyed");
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
// =============================================
|
|
||||||
// Aster: glfw_context.h
|
|
||||||
// Copyright (c) 2020-2024 Anish Bhobe
|
|
||||||
// =============================================
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "global.h"
|
|
||||||
|
|
||||||
struct GlfwContext
|
|
||||||
{
|
|
||||||
|
|
||||||
static i32
|
|
||||||
PostError() noexcept
|
|
||||||
{
|
|
||||||
static const char *error = nullptr;
|
|
||||||
const auto code = glfwGetError(&error);
|
|
||||||
ERROR("GLFW {}", error);
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline static u32 m_Count = 0;
|
|
||||||
|
|
||||||
GlfwContext()
|
|
||||||
{
|
|
||||||
if (m_Count++ > 0)
|
|
||||||
return;
|
|
||||||
if (glfwInit() == GLFW_FALSE)
|
|
||||||
{
|
|
||||||
ABORT(PostError());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
~GlfwContext()
|
|
||||||
{
|
|
||||||
if (--m_Count == 0)
|
|
||||||
{
|
|
||||||
glfwTerminate();
|
|
||||||
}
|
|
||||||
m_Count = 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -121,4 +121,4 @@ struct fmt::formatter<eastl::fixed_string<TType, TCount, TOverflow>> : nested_fo
|
||||||
{
|
{
|
||||||
return write_padded(ctx, [this, str](auto out) { return v10::format_to(out, "{}", nested(str.c_str())); });
|
return write_padded(ctx, [this, str](auto out) { return v10::format_to(out, "{}", nested(str.c_str())); });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
|
||||||
#include "context.h"
|
#include "context.h"
|
||||||
#include "glfw_context.h"
|
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -50,9 +49,10 @@ Window::Window(const cstr title, Context *context, vk::Extent2D extent, const b8
|
||||||
ELSE_DEBUG("Window '{}' created with resolution '{}x{}'", m_Name, extent.width, extent.height);
|
ELSE_DEBUG("Window '{}' created with resolution '{}x{}'", m_Name, extent.width, extent.height);
|
||||||
if (m_Window == nullptr)
|
if (m_Window == nullptr)
|
||||||
{
|
{
|
||||||
auto code = GlfwContext::PostError();
|
const char *error = nullptr;
|
||||||
glfwTerminate();
|
const auto code = glfwGetError(&error);
|
||||||
ABORT(code);
|
ERROR("GLFW Window Creation failed. Cause: ({}) {}", code, error)
|
||||||
|
THEN_ABORT(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFullScreen == false)
|
if (isFullScreen == false)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# CMakeList.txt ; CMake project for Aster Core
|
# CMakeList.txt ; CMake project for Triangle
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
|
// =============================================
|
||||||
|
// Aster: triangle.cpp
|
||||||
|
// Copyright (c) 2020-2024 Anish Bhobe
|
||||||
|
// =============================================
|
||||||
|
|
||||||
#include "aster/constants.h"
|
#include "aster/constants.h"
|
||||||
#include "aster/context.h"
|
#include "aster/context.h"
|
||||||
#include "aster/device.h"
|
#include "aster/device.h"
|
||||||
#include "aster/glfw_context.h"
|
|
||||||
#include "aster/physical_device.h"
|
#include "aster/physical_device.h"
|
||||||
#include "aster/window.h"
|
#include "aster/window.h"
|
||||||
|
|
||||||
|
|
@ -13,6 +17,8 @@
|
||||||
#include <EASTL/optional.h>
|
#include <EASTL/optional.h>
|
||||||
|
|
||||||
constexpr u32 MAX_FRAMES_IN_FLIGHT = 3;
|
constexpr u32 MAX_FRAMES_IN_FLIGHT = 3;
|
||||||
|
constexpr auto VERTEX_SHADER_FILE = "shader/triangle.vs.hlsl.spv";
|
||||||
|
constexpr auto FRAGMENT_SHADER_FILE = "shader/white.frag.glsl.spv";
|
||||||
|
|
||||||
bool IsSuitableDevice(const PhysicalDevice *physicalDevice);
|
bool IsSuitableDevice(const PhysicalDevice *physicalDevice);
|
||||||
PhysicalDevice FindSuitableDevice(const PhysicalDevices &physicalDevices);
|
PhysicalDevice FindSuitableDevice(const PhysicalDevices &physicalDevices);
|
||||||
|
|
@ -48,9 +54,8 @@ main(int, char **)
|
||||||
{
|
{
|
||||||
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
||||||
|
|
||||||
GlfwContext glfwContext = {};
|
Context context = {"Triangle", VERSION};
|
||||||
Context context = {"Aster", VERSION};
|
Window window = {"Triangle (Aster)", &context, {640, 480}};
|
||||||
Window window = {"Aster1", &context, {640, 480}};
|
|
||||||
|
|
||||||
PhysicalDevices physicalDevices = {&window, &context};
|
PhysicalDevices physicalDevices = {&window, &context};
|
||||||
PhysicalDevice deviceToUse = FindSuitableDevice(physicalDevices);
|
PhysicalDevice deviceToUse = FindSuitableDevice(physicalDevices);
|
||||||
|
|
@ -65,10 +70,7 @@ main(int, char **)
|
||||||
|
|
||||||
Swapchain swapchain = {&window, &device, "Primary Chain"};
|
Swapchain swapchain = {&window, &device, "Primary Chain"};
|
||||||
|
|
||||||
auto vertexShaderFile = "shader/triangle.vs.hlsl.spv";
|
Pipeline pipeline = CreatePipeline(&device, &swapchain, VERTEX_SHADER_FILE, FRAGMENT_SHADER_FILE);
|
||||||
auto fragmentShaderFile = "shader/white.frag.glsl.spv";
|
|
||||||
|
|
||||||
Pipeline pipeline = CreatePipeline(&device, &swapchain, vertexShaderFile, fragmentShaderFile);
|
|
||||||
|
|
||||||
// Persistent variables
|
// Persistent variables
|
||||||
vk::Viewport viewport = {
|
vk::Viewport viewport = {
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
# CMakeList.txt ; CMake project for Samples
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
|
add_subdirectory("01_triangle")
|
||||||
Loading…
Reference in New Issue