evan 2026.1.4
Evan
Loading...
Searching...
No Matches
WindowsPlatoform.cpp
1/*
2** ETIB PROJECT, 2026
3** evan
4** File description:
5** WindowsPlatoform
6*/
7
8#include "evan/glfw/platform/WindowsPlatform.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 WindowsDesktopPlatform 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
45 if (enableValidationLayers == true) {
47 }
48 return std::vector<std::string>(extensions.begin(), extensions.end());
49}
50
53{
54 this->getLogger().info()
55 << "Creating Vulkan surface for WindowsDesktopPlatform";
56
58 if (glfwCreateWindowSurface(instance, _window, nullptr, &surface)
59 != VK_SUCCESS) {
60 throw std::runtime_error("Failed to create Vulkan surface");
61 }
62 this->getLogger().info() << "Vulkan surface created successfully";
63 return surface;
64}
65
67// Protected Methods //
69
70std::filesystem::path
72{
73 const char *localAppData = std::getenv("LOCALAPPDATA");
74 if (localAppData == nullptr || localAppData[0] == '\0') {
75 return {};
76 }
77 return std::filesystem::path(localAppData);
78}
GLFWwindow * _window
Currently active GLFW window for the Desktop platform.
VkSurfaceKHR createSurface(VkInstance instance) const override
Create a Vulkan surface for the Windows desktop platform.
std::vector< std::string > getRequiredInstanceExtensions() const override
Get the required instance extensions for the Windows desktop platform.
WindowsDesktopPlatform(const std::string &name, const uint32_t width, const uint32_t height)
Constructor for WindowsDesktopPlatform.
std::filesystem::path getDefaultCacheRoot() const override
Get the Windows cache root directory.
Small result wrapper used by helpers that must return both a status and a value (e....
Definition Error.hpp:89