Dodo 0.1
Template for CPP projects
Loading...
Searching...
No Matches
/github/workspace/main.cpp File Reference
#include <vulkan/vulkan_raii.hpp>
#include <cstdlib>
#include <iostream>
#include <stdexcept>
#include "GLFW/glfw3.h"
#include "dodo/core/App.hpp"
Include dependency graph for main.cpp:

Classes

class  HelloTriangleApplication
 
struct  Test< Features >
 

Functions

template<typename T >
void printType ()
 
template<typename FirstFeature , typename... OtherFeatures>
void testStructureChains (const vk::StructureChain< FirstFeature, OtherFeatures... > &features)
 
int main ()
 

Variables

const std::vector< char const * > validationLayers
 
constexpr bool enableValidationLayers = true
 

Function Documentation

◆ main()

int main ( )
341 {
342 std::array<const char *, 1> vLayers {
343 "VK_LAYER_KHRONOS_validation",
344 };
345
346
347 const vk::ApplicationInfo vkInfo {
348 .pApplicationName = "Hello Triangle",
349 .applicationVersion = VK_MAKE_VERSION( 1, 0, 0 ),
350 .pEngineName = "No Engine",
351 .engineVersion = VK_MAKE_VERSION( 1, 0, 0 ),
352 .apiVersion = vk::ApiVersion13
353 };
354
355 const dodo::core::App::AppInfo appInfo {
356 .width = 800,
357 .height = 600,
358 .title = "TestApplication"
359 };
360
361 vk::StructureChain<vk::PhysicalDeviceFeatures2,
362 vk::PhysicalDeviceVulkan13Features,
363 vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT> featureChain = {
364 {}, // vk::PhysicalDeviceFeatures2 (empty for now)
365 {.dynamicRendering = true }, // Enable dynamic rendering from Vulkan 1.3
366 {.extendedDynamicState = true }, // Enable extended dynamic state from the extension
367 };
368
370 .debugEnabled = true,
371 .validationLayers = vLayers,
372 };
373
374 const dodo::core::VulkanContext::VulkanContextInfo<vk::PhysicalDeviceFeatures2,
375 vk::PhysicalDeviceVulkan13Features,
376 vk::PhysicalDeviceExtendedDynamicStateFeaturesEXT> vkCtxInfo {
377 .vkInfo = vkInfo,
378 .featureChain = featureChain,
379 .debugInfo = debugInfo
380 };
381
382 auto ctx = dodo::core::DodoContext::createDodoContext(vkCtxInfo);
383 auto app = dodo::core::App::createApp(*ctx, appInfo);
384 if (app) {
385 std::cout << "Success" << std::endl;
386 } else {
387 std::cout << app.error() << std::endl;
388 return EXIT_FAILURE;
389 }
390 while (app->isRunning()) {
391 app->pollEvents();
392 }
393 // HelloTriangleApplication app;
394 // try {
395 // app.run();
396 // } catch (const std::exception& e) {
397 // std::cerr << e.what() << std::endl;
398 // return EXIT_FAILURE;
399 // }
400 return EXIT_SUCCESS;
401}
static auto createApp(const DodoContext &ctx, const AppInfo &appInfo) -> std::expected< App, std::string >
Definition App.cpp:9
static auto createDodoContext(const VulkanContext::VulkanContextInfo< Features... > &ctxInfo) -> std::expected< DodoContext, std::string >
Definition DodoContext.hpp:39
Definition App.hpp:22
Definition VulkanContext.hpp:38
Definition VulkanContext.hpp:31

References dodo::core::App::createApp(), and dodo::core::DodoContext::createDodoContext().

Here is the call graph for this function:

◆ printType()

template<typename T >
void printType ( )
319{
320#if defined(__clang__) || defined(__GNUC__)
321 std::cout << __PRETTY_FUNCTION__ << '\n';
322#elif defined(_MSC_VER)
323 std::cout << __FUNCSIG__ << '\n';
324#endif
325}

Referenced by testStructureChains().

Here is the caller graph for this function:

◆ testStructureChains()

template<typename FirstFeature , typename... OtherFeatures>
void testStructureChains ( const vk::StructureChain< FirstFeature, OtherFeatures... > & features)
328 {
329 const auto &first = features.template get<FirstFeature>();
331
332 vk::DeviceCreateInfo deviceCreateInfo{
333 .pNext = &first,
334 .queueCreateInfoCount = 1,
335 // .pQueueCreateInfos = &deviceQueueCreateInfo,
336 // .enabledExtensionCount = static_cast<uint32_t>(deviceExtensions.size()),
337 // .ppEnabledExtensionNames = deviceExtensions.data()
338 };
339}
void printType()
Definition main.cpp:318

References printType().

Here is the call graph for this function:

Variable Documentation

◆ enableValidationLayers

bool enableValidationLayers = true
constexpr

◆ validationLayers

const std::vector<char const*> validationLayers
Initial value:
= {
"VK_LAYER_KHRONOS_validation"
}
28 {
29 "VK_LAYER_KHRONOS_validation"
30};

Referenced by dodo::core::VulkanContext::checkRequiredLayers(), and HelloTriangleApplication::createInstance().