evan 2026.1.4
Evan
Loading...
Searching...
No Matches
evan::glfw::GlfwContext Class Reference

Reference-counted GLFW lifecycle guard. More...

#include <headers/evan/glfw/GlfwContext.hpp>

Public Member Functions

 GlfwContext ()
 Acquires the GLFW library.
 
 ~GlfwContext ()=default
 Releases the GLFW library.
 
 GlfwContext (const GlfwContext &)=default
 
 GlfwContext (GlfwContext &&) noexcept=default
 
GlfwContext & operator= (const GlfwContext &)=default
 
GlfwContext & operator= (GlfwContext &&) noexcept=default
 

Detailed Description

Reference-counted GLFW lifecycle guard.

GLFW is process-global state: glfwInit() and glfwTerminate() must not be paired per platform instance, otherwise destroying one platform tears down GLFW for every other live platform. This guard acquires the library when the first instance is created and releases it when the last instance is destroyed.

The type is copyable and movable; copies share the same underlying reference count (backed by std::shared_ptr).

Definition at line 26 of file GlfwContext.hpp.

Constructor & Destructor Documentation

◆ GlfwContext()

evan::glfw::GlfwContext::GlfwContext ( )

Acquires the GLFW library.

Increments the global reference count and calls glfwInit() on the first acquisition.

Exceptions
std::runtime_errorIf glfwInit() fails.

Definition at line 51 of file GlfwContext.cpp.

◆ ~GlfwContext()

evan::glfw::GlfwContext::~GlfwContext ( )
default

Releases the GLFW library.

Decrements the global reference count and calls glfwTerminate() when the last guard is destroyed.


The documentation for this class was generated from the following files: