evan 2026.1.4
Evan
Loading...
Searching...
No Matches
GlfwContext.cpp
1/*
2** ETIB PROJECT, 2026
3** evan
4** File description:
5** GlfwContext
6*/
7
8#include "evan/glfw/GlfwContext.hpp"
9
10#include "evan/EvanPlatform.hpp"
11
12#include <stdexcept>
13
14namespace
15{
23 struct GlfwState {
24 GlfwState()
25 {
26 if (!glfwInit()) {
27 throw std::runtime_error("Failed to initialize GLFW");
28 }
29 }
30
31 ~GlfwState()
32 {
33 glfwTerminate();
34 }
35 };
36
37 std::shared_ptr<void> acquireGlfw()
38 {
39 static std::weak_ptr<void> weak;
40
41 if (auto guard = weak.lock()) {
42 return guard;
43 }
44
45 auto guard = std::shared_ptr<void>(new GlfwState());
46 weak = guard;
47 return guard;
48 }
49} // namespace
50
GlfwContext()
Acquires the GLFW library.
Small result wrapper used by helpers that must return both a status and a value (e....
Definition Error.hpp:89