Dodo 0.1
Template for CPP projects
Loading...
Searching...
No Matches
DodoContext.hpp
Go to the documentation of this file.
1//
2// Created by nicol on 21/02/2026.
3//
4
5#ifndef DODO_DODOCONTEXT_HPP
6#define DODO_DODOCONTEXT_HPP
7
8#include <utility>
9
10#include "GLFWContext.hpp"
11#include "VulkanContext.hpp"
12
13namespace dodo::core {
14
16private:
19
20 DodoContext() = default;
21public:
22 template<typename... Features>
24 -> std::expected<DodoContext, std::string>;
25
26 ~DodoContext() = default;
27
28 DodoContext(const DodoContext &other) = delete;
29
30 DodoContext &operator=(const DodoContext &other) = delete;
31
32 DodoContext(DodoContext &&other) noexcept;
33
34 DodoContext &operator=(DodoContext &&other) noexcept;
35};
36
37
38template <typename... Features>
40 -> std::expected<DodoContext, std::string> {
41 auto glfwContext = GLFWContext::createContext();
42 if (!glfwContext)
43 return std::unexpected("Failed to create GLFW context: " + glfwContext.error());
44 auto vulkanContext = VulkanContext::createContext(ctxInfo);
45 if (!vulkanContext)
46 return std::unexpected("Failed to create Vulkan context: " + vulkanContext.error());
47 DodoContext dodoContext;
48 dodoContext._glfwContext = std::move(*glfwContext);
49 dodoContext._vulkanContext = std::move(*vulkanContext);
50 return dodoContext;
51}
52
53}
54
55#endif // DODO_DODOCONTEXT_HPP
Definition DodoContext.hpp:15
static auto createDodoContext(const VulkanContext::VulkanContextInfo< Features... > &ctxInfo) -> std::expected< DodoContext, std::string >
Definition DodoContext.hpp:39
DodoContext & operator=(const DodoContext &other)=delete
VulkanContext _vulkanContext
Definition DodoContext.hpp:18
DodoContext(const DodoContext &other)=delete
GLFWContext _glfwContext
Definition DodoContext.hpp:17
Definition GLFWContext.hpp:19
static auto createContext() -> std::expected< GLFWContext, std::string >
Definition GLFWContext.cpp:11
Definition VulkanContext.hpp:22
static auto createContext(const VulkanContextInfo< Features... > &ctxInfo) -> std::expected< VulkanContext, std::string >
Definition VulkanContext.hpp:82
Definition App.cpp:7
Definition VulkanContext.hpp:38