File hierarchy cleanup.
This commit is contained in:
parent
5744e7a13c
commit
ccb0aa5fbe
|
|
@ -19,4 +19,4 @@ endif ()
|
|||
include(add_shader.cmake)
|
||||
|
||||
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");
|
||||
|
||||
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
|
||||
const vk::ApplicationInfo appInfo = {
|
||||
.pApplicationName = appName,
|
||||
|
|
@ -109,4 +119,6 @@ Context::~Context()
|
|||
}
|
||||
m_Instance.destroy(nullptr);
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
|
@ -6,7 +6,6 @@
|
|||
#include "window.h"
|
||||
|
||||
#include "context.h"
|
||||
#include "glfw_context.h"
|
||||
#include "logger.h"
|
||||
|
||||
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);
|
||||
if (m_Window == nullptr)
|
||||
{
|
||||
auto code = GlfwContext::PostError();
|
||||
glfwTerminate();
|
||||
ABORT(code);
|
||||
const char *error = nullptr;
|
||||
const auto code = glfwGetError(&error);
|
||||
ERROR("GLFW Window Creation failed. Cause: ({}) {}", code, error)
|
||||
THEN_ABORT(code);
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
|
|
@ -1,7 +1,11 @@
|
|||
// =============================================
|
||||
// Aster: triangle.cpp
|
||||
// Copyright (c) 2020-2024 Anish Bhobe
|
||||
// =============================================
|
||||
|
||||
#include "aster/constants.h"
|
||||
#include "aster/context.h"
|
||||
#include "aster/device.h"
|
||||
#include "aster/glfw_context.h"
|
||||
#include "aster/physical_device.h"
|
||||
#include "aster/window.h"
|
||||
|
||||
|
|
@ -13,6 +17,8 @@
|
|||
#include <EASTL/optional.h>
|
||||
|
||||
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);
|
||||
PhysicalDevice FindSuitableDevice(const PhysicalDevices &physicalDevices);
|
||||
|
|
@ -48,9 +54,8 @@ main(int, char **)
|
|||
{
|
||||
MIN_LOG_LEVEL(Logger::LogType::eInfo);
|
||||
|
||||
GlfwContext glfwContext = {};
|
||||
Context context = {"Aster", VERSION};
|
||||
Window window = {"Aster1", &context, {640, 480}};
|
||||
Context context = {"Triangle", VERSION};
|
||||
Window window = {"Triangle (Aster)", &context, {640, 480}};
|
||||
|
||||
PhysicalDevices physicalDevices = {&window, &context};
|
||||
PhysicalDevice deviceToUse = FindSuitableDevice(physicalDevices);
|
||||
|
|
@ -65,10 +70,7 @@ main(int, char **)
|
|||
|
||||
Swapchain swapchain = {&window, &device, "Primary Chain"};
|
||||
|
||||
auto vertexShaderFile = "shader/triangle.vs.hlsl.spv";
|
||||
auto fragmentShaderFile = "shader/white.frag.glsl.spv";
|
||||
|
||||
Pipeline pipeline = CreatePipeline(&device, &swapchain, vertexShaderFile, fragmentShaderFile);
|
||||
Pipeline pipeline = CreatePipeline(&device, &swapchain, VERTEX_SHADER_FILE, FRAGMENT_SHADER_FILE);
|
||||
|
||||
// Persistent variables
|
||||
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