Dodo 0.1
Template for CPP projects
Loading...
Searching...
No Matches
dodo::core::GLFWContext Class Reference

#include <GLFWContext.hpp>

Public Member Functions

 ~GLFWContext ()
 
 GLFWContext (const GLFWContext &other)=delete
 
GLFWContextoperator= (const GLFWContext &other)=delete
 
 GLFWContext (GLFWContext &&other) noexcept
 
GLFWContextoperator= (GLFWContext &&other) noexcept
 

Private Member Functions

 GLFWContext ()=default
 

Static Private Member Functions

static auto createContext () -> std::expected< GLFWContext, std::string >
 

Private Attributes

bool _ownsContext = false
 

Static Private Attributes

static bool _initialized = false
 

Friends

class DodoContext
 

Constructor & Destructor Documentation

◆ ~GLFWContext()

dodo::core::GLFWContext::~GLFWContext ( )
29 {
30 if (_ownsContext) {
32 _initialized = false;
33 }
34}
bool _ownsContext
Definition GLFWContext.hpp:22
static bool _initialized
Definition GLFWContext.hpp:21
GLFWAPI void glfwTerminate(void)
Terminates the GLFW library.

References _initialized, _ownsContext, and glfwTerminate().

Here is the call graph for this function:

◆ GLFWContext() [1/3]

dodo::core::GLFWContext::GLFWContext ( const GLFWContext & other)
delete

◆ GLFWContext() [2/3]

dodo::core::GLFWContext::GLFWContext ( GLFWContext && other)
noexcept
22 : _ownsContext(std::exchange(other._ownsContext, false)) {}

◆ GLFWContext() [3/3]

dodo::core::GLFWContext::GLFWContext ( )
privatedefault

Member Function Documentation

◆ createContext()

auto dodo::core::GLFWContext::createContext ( ) -> std::expected<GLFWContext, std::string>
staticprivate
11 {
12 if (_initialized) return std::unexpected("GLFW is already initialized");
13 if (const char* errorBuf; !glfwInit()) {
14 glfwGetError(&errorBuf);
15 return std::unexpected(errorBuf);
16 }
17 _initialized = true;
18 return GLFWContext();
19}
GLFWAPI int glfwInit(void)
Initializes the GLFW library.
GLFWAPI int glfwGetError(const char **description)
Returns and clears the last error for the calling thread.

References glfwGetError(), and glfwInit().

Referenced by dodo::core::DodoContext::createDodoContext().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [1/2]

GLFWContext & dodo::core::GLFWContext::operator= ( const GLFWContext & other)
delete

◆ operator=() [2/2]

GLFWContext & dodo::core::GLFWContext::operator= ( GLFWContext && other)
noexcept
24 {
25 if (this != &other) _ownsContext = std::exchange(other._ownsContext, false);
26 return *this;
27}

Friends And Related Symbol Documentation

◆ DodoContext

friend class DodoContext
friend

Member Data Documentation

◆ _initialized

bool dodo::core::GLFWContext::_initialized = false
inlinestaticprivate

Referenced by ~GLFWContext().

◆ _ownsContext

bool dodo::core::GLFWContext::_ownsContext = false
private

Referenced by ~GLFWContext().


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