what
This commit is contained in:
parent
df0e12a783
commit
0d77992e67
31
src/main.cpp
31
src/main.cpp
|
@ -3,20 +3,19 @@
|
|||
#include <iostream>
|
||||
#include <set>
|
||||
|
||||
#define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1
|
||||
#define VK_ENABLE_BETA_EXTENSIONS
|
||||
#define VULKAN_HPP_NO_CONSTRUCTORS
|
||||
#define VULKAN_HPP_NO_EXCEPTIONS
|
||||
#include <vulkan/vulkan.hpp>
|
||||
|
||||
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE
|
||||
|
||||
#include "util/types.h"
|
||||
|
||||
#define VKFW_NO_STD_FUNCTION_CALLBACKS
|
||||
#include "vkfw.hpp"
|
||||
|
||||
namespace vk {
|
||||
using DebugUtilsMessengerUnique = vk::UniqueHandle<vk::DebugUtilsMessengerEXT, vk::DispatchLoaderDynamic>;
|
||||
}
|
||||
|
||||
constexpr i32 WIDTH = 800;
|
||||
constexpr i32 HEIGHT = 600;
|
||||
|
||||
|
@ -51,8 +50,7 @@ class VulkanApp {
|
|||
|
||||
vk::UniqueInstance mInstance;
|
||||
|
||||
vk::DebugUtilsMessengerUnique mDebugMessenger;
|
||||
vk::DispatchLoaderDynamic mLoader;
|
||||
vk::UniqueDebugUtilsMessengerEXT mDebugMessenger;
|
||||
vk::UniqueSurfaceKHR mSurface;
|
||||
|
||||
vk::PhysicalDevice mPhysicalDevice;
|
||||
|
@ -160,14 +158,10 @@ class VulkanApp {
|
|||
}
|
||||
|
||||
fn cleanupSwapChain() -> void {
|
||||
for (vk::UniqueHandle<vk::Framebuffer, vk::DispatchLoaderStatic>& mSwapChainFramebuffer :
|
||||
mSwapChainFramebuffers) {
|
||||
for (vk::UniqueFramebuffer& mSwapChainFramebuffer : mSwapChainFramebuffers) {
|
||||
mSwapChainFramebuffer.reset();
|
||||
}
|
||||
for (vk::UniqueHandle<vk::ImageView, vk::DispatchLoaderStatic>& mSwapChainImageView :
|
||||
mSwapChainImageViews) {
|
||||
mSwapChainImageView.reset();
|
||||
}
|
||||
for (vk::UniqueImageView& mSwapChainImageView : mSwapChainImageViews) { mSwapChainImageView.reset(); }
|
||||
|
||||
mSwapChain.reset();
|
||||
}
|
||||
|
@ -201,7 +195,7 @@ class VulkanApp {
|
|||
.applicationVersion = 1,
|
||||
.pEngineName = "No Engine",
|
||||
.engineVersion = 1,
|
||||
.apiVersion = vk::ApiVersion10 };
|
||||
.apiVersion = vk::ApiVersion12 };
|
||||
|
||||
// Retrieve extensions using custom function
|
||||
std::vector<const char*> extensions = getRequiredExtensions();
|
||||
|
@ -233,7 +227,7 @@ class VulkanApp {
|
|||
#endif
|
||||
|
||||
mInstance = vk::createInstanceUnique(createInfo).value;
|
||||
mLoader = vk::DispatchLoaderDynamic(mInstance.get(), vkGetInstanceProcAddr);
|
||||
VULKAN_HPP_DEFAULT_DISPATCHER.init(mInstance.get());
|
||||
}
|
||||
|
||||
fn setupDebugMessenger() -> void {
|
||||
|
@ -251,7 +245,9 @@ class VulkanApp {
|
|||
};
|
||||
|
||||
mDebugMessenger =
|
||||
mInstance->createDebugUtilsMessengerEXTUnique(messengerCreateInfo, nullptr, mLoader).value;
|
||||
mInstance
|
||||
->createDebugUtilsMessengerEXTUnique(messengerCreateInfo, nullptr, VULKAN_HPP_DEFAULT_DISPATCHER)
|
||||
.value;
|
||||
}
|
||||
|
||||
fn createSurface() -> void { mSurface = vkfw::createWindowSurfaceUnique(mInstance.get(), mWindow.get()); }
|
||||
|
@ -817,6 +813,11 @@ class VulkanApp {
|
|||
};
|
||||
|
||||
fn main() -> i32 {
|
||||
vk::DynamicLoader dynamicLoader;
|
||||
auto vkGetInstanceProcAddr =
|
||||
dynamicLoader.getProcAddress<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr");
|
||||
VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr);
|
||||
|
||||
VulkanApp app;
|
||||
|
||||
try {
|
||||
|
|
Loading…
Reference in a new issue