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
14
namespace
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
51
evan::glfw::GlfwContext::GlfwContext
()
52
: _state(
acquireGlfw
())
53
{
54
}
evan::glfw::GlfwContext::GlfwContext
GlfwContext()
Acquires the GLFW library.
Definition
GlfwContext.cpp:51
evan::Result
Small result wrapper used by helpers that must return both a status and a value (e....
Definition
Error.hpp:89
sources
glfw
GlfwContext.cpp
Generated by
1.9.8