evan 2026.1.4
Evan
Loading...
Searching...
No Matches
LinuxDesktopPlatform.cpp
1/*
2** ETIB PROJECT, 2026
3** evan
4** File description:
5** LinuxDesktopPlatform
6*/
7
8#include "evan/glfw/platform/LinuxDesktopPlatform.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 LinuxDesktopPlatform 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
27 if (!_window) {
28 this->getLogger().error() << "Failed to create GLFW window";
29 throw std::runtime_error("Failed to create GLFW window");
30 }
31}
32
34// Public Methods //
36
37std::vector<std::string>
39{
41 const char **glfwExtensions =
43 std::vector<const char *> extensions(glfwExtensions,
45
46 if (enableValidationLayers == true) {
48 }
49 return std::vector<std::string>(extensions.begin(), extensions.end());
50}
51
54{
55 this->getLogger().info()
56 << "Creating Vulkan surface for LinuxDesktopPlatform";
57
59 if (glfwCreateWindowSurface(instance, _window, nullptr, &surface)
60 != VK_SUCCESS) {
61 throw std::runtime_error("Failed to create Vulkan surface");
62 }
63 this->getLogger().info() << "Vulkan surface created successfully";
64 return surface;
65}
66
68// Protected Methods //
70
71std::filesystem::path
73{
74 const char *xdgCache = std::getenv("XDG_CACHE_HOME");
75 if (xdgCache != nullptr && xdgCache[0] != '\0') {
76 return std::filesystem::path(xdgCache);
77 }
78
79 const char *home = std::getenv("HOME");
80 if (home == nullptr || home[0] == '\0') {
81 return {};
82 }
83 return std::filesystem::path(home) / ".cache";
84}
GLFWwindow * _window
Currently active GLFW window for the Desktop platform.
VkSurfaceKHR createSurface(VkInstance instance) const override
Create a Vulkan surface for the Linux desktop platform.
std::filesystem::path getDefaultCacheRoot() const override
Get the Linux cache root directory.
LinuxDesktopPlatform(const std::string &name, const uint32_t width, const uint32_t height)
Constructor for LinuxDesktopPlatform.
std::vector< std::string > getRequiredInstanceExtensions() const override
Get the required instance extensions for the Linux desktop platform.
Small result wrapper used by helpers that must return both a status and a value (e....
Definition Error.hpp:89