evan 2026.1.4
Evan
Loading...
Searching...
No Matches
MacOsDesktopPlatform.cpp
1/*
2** ETIB PROJECT, 2026
3** evan
4** File description:
5** MacOsDesktopPlatform
6*/
7
8#include "evan/glfw/platform/MacOsDesktopPlatform.hpp"
9
10#include <cstdlib>
11#include <stdexcept>
12
14 const uint32_t width,
15 const uint32_t height)
16{
17 this->getLogger().info()
18 << "Initializing MacOsDesktopPlatform with window name: " << name
19 << ", width: " << width << ", height: " << height;
20
23
24 this->getLogger().info() << "Creating GLFW window";
25 _window = glfwCreateWindow(width, height, name.c_str(), nullptr, nullptr);
26 if (!_window) {
27 this->getLogger().error() << "Failed to create GLFW window";
28 throw std::runtime_error("Failed to create GLFW window");
29 }
30}
31
33// Public Methods //
35
36std::vector<std::string>
38{
40 const char **glfwExtensions =
42 std::vector<const char *> extensions(glfwExtensions,
44
46
47 if (enableValidationLayers == true) {
49 }
50 return std::vector<std::string>(extensions.begin(), extensions.end());
51}
52
57
58std::vector<std::string>
60{
61 return { "VK_KHR_portability_subset" };
62}
63
66{
67 this->getLogger().info()
68 << "Creating Vulkan surface for MacOsDesktopPlatform";
69
71 if (glfwCreateWindowSurface(instance, _window, nullptr, &surface)
72 != VK_SUCCESS) {
73 throw std::runtime_error("Failed to create Vulkan surface");
74 }
75 this->getLogger().info() << "Vulkan surface created successfully";
76 return surface;
77}
78
80// Protected Methods //
82
83std::filesystem::path
85{
86 const char *home = std::getenv("HOME");
87 if (home == nullptr || home[0] == '\0') {
88 return {};
89 }
90 return std::filesystem::path(home) / "Library" / "Caches";
91}
GLFWwindow * _window
Currently active GLFW window for the Desktop platform.
std::vector< std::string > getRequiredDeviceExtensions() const override
Get the required Vulkan device extensions for the MacOS desktop platform.
MacOsDesktopPlatform(const std::string &name, const uint32_t width, const uint32_t height)
Constructor for MacOsDesktopPlatform.
std::filesystem::path getDefaultCacheRoot() const override
Get the macOS cache root directory.
VkSurfaceKHR createSurface(VkInstance instance) const override
Create a Vulkan surface for the MacOS desktop platform.
std::vector< std::string > getRequiredInstanceExtensions() const override
Get the required instance extensions for the MacOS desktop platform.
VkInstanceCreateFlags getInstanceCreateFlags() const override
Get the Vulkan instance creation flags for the MacOS desktop platform.
Small result wrapper used by helpers that must return both a status and a value (e....
Definition Error.hpp:89