Feature/VkExtensions+VkLayers (#2)

This commit is contained in:
Preston McGee
2026-05-16 12:48:39 -07:00
committed by GitHub
parent 836012648b
commit a63c271f92
5 changed files with 213 additions and 23 deletions

View File

@@ -1,6 +1,9 @@
#pragma once
// resource allocation is initializion my beloved
#include <vulkan/vulkan_raii.hpp>
#include "Window.hpp"
class Engine {
@@ -10,6 +13,7 @@ public:
Engine(Window* window);
~Engine() = default;
// initializes and sets up the vulkan instance. outside of constructor to allow control of order the order of initialization
void init();
// draw is called every render iteration in that while loop
@@ -17,8 +21,30 @@ public:
private:
// might get rid of this
// returns a list of the required extensions needed by our engine
std::vector<const char*> getRequiredInstanceExtensions();
// helper for organizing the creation of the vulkan instance. returns success or failure
bool createInstance();
// helper for attaching callbacks to the instance
bool initDebugMessenger();
// callback function for the vulkan debug extension: routes debug messages from validation layers to our app
static VKAPI_ATTR vk::Bool32 VKAPI_CALL debugCallback(vk::DebugUtilsMessageSeverityFlagBitsEXT severity,
vk::DebugUtilsMessageTypeFlagsEXT type,
const vk::DebugUtilsMessengerCallbackDataEXT* pCallbackData,
void* pUserData);
Window* window_;
// Vulkan specific instance members
vk::raii::Context context_;
vk::raii::Instance instance_ = nullptr;
vk::raii::DebugUtilsMessengerEXT debugMessenger_ = nullptr;
// members for control over validation layers
static constexpr bool enableValidationLayers = true; // TODO: only true in debug mode
const std::vector<const char*> validationLayers = { "VK_LAYER_KHRONOS_validation" };
};