MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Hpp / main

Function main

RAII_Samples/12_InitFrameBuffers/12_InitFrameBuffers.cpp:14–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12static char const * EngineName = "Vulkan.hpp";
13
14int main()
15{
16 try
17 {
18 vk::raii::Context context;
19 vk::raii::Instance instance = vk::raii::su::makeInstance( context, AppName, EngineName, {}, vk::su::getInstanceExtensions() );
20#if !defined( NDEBUG )
21 vk::raii::DebugUtilsMessengerEXT debugUtilsMessenger( instance, vk::su::makeDebugUtilsMessengerCreateInfoEXT() );
22#endif
23 vk::raii::PhysicalDevice physicalDevice = vk::raii::PhysicalDevices( instance ).front();
24
25 vk::raii::su::SurfaceData surfaceData( instance, AppName, vk::Extent2D( 64, 64 ) );
26
27 std::pair<uint32_t, uint32_t> graphicsAndPresentQueueFamilyIndex =
28 vk::raii::su::findGraphicsAndPresentQueueFamilyIndex( physicalDevice, surfaceData.surface );
29 vk::raii::Device device = vk::raii::su::makeDevice( physicalDevice, graphicsAndPresentQueueFamilyIndex.first, vk::su::getDeviceExtensions() );
30
31 vk::raii::su::SwapChainData swapChainData( physicalDevice,
32 device,
33 surfaceData.surface,
34 surfaceData.extent,
35 vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eTransferSrc,
36 {},
37 graphicsAndPresentQueueFamilyIndex.first,
38 graphicsAndPresentQueueFamilyIndex.second );
39
40 vk::raii::su::DepthBufferData depthBufferData( physicalDevice, device, vk::Format::eD16Unorm, surfaceData.extent );
41
42 vk::raii::RenderPass renderPass = vk::raii::su::makeRenderPass( device, swapChainData.colorFormat, depthBufferData.format );
43
44 /* VULKAN_KEY_START */
45
46 std::array<vk::ImageView, 2> attachments;
47 attachments[1] = depthBufferData.imageView;
48
49 std::vector<vk::raii::Framebuffer> framebuffers;
50 framebuffers.reserve( swapChainData.imageViews.size() );
51 for ( auto const & view : swapChainData.imageViews )
52 {
53 attachments[0] = view;
54 vk::FramebufferCreateInfo framebufferCreateInfo( {}, renderPass, attachments, surfaceData.extent.width, surfaceData.extent.height, 1 );
55 framebuffers.push_back( vk::raii::Framebuffer( device, framebufferCreateInfo ) );
56 }
57
58 /* VULKAN_KEY_END */
59 }
60 catch ( vk::SystemError & err )
61 {
62 std::cout << "vk::SystemError: " << err.what() << std::endl;
63 exit( -1 );
64 }
65 catch ( std::exception & err )
66 {
67 std::cout << "std::exception: " << err.what() << std::endl;
68 exit( -1 );
69 }
70 catch ( ... )
71 {

Callers

nothing calls this directly

Calls 7

makeInstanceFunction · 0.85
getInstanceExtensionsFunction · 0.85
makeDeviceFunction · 0.85
getDeviceExtensionsFunction · 0.85
makeRenderPassFunction · 0.85

Tested by

no test coverage detected