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

#include <App.hpp>

Classes

struct  AppInfo
 

Public Member Functions

 ~App ()
 
 App (const App &other)=delete
 
Appoperator= (const App &other)=delete
 
 App (App &&other) noexcept
 
Appoperator= (App &&other) noexcept
 
bool isRunning () const
 
void pollEvents () const
 

Static Public Member Functions

static auto createApp (const DodoContext &ctx, const AppInfo &appInfo) -> std::expected< App, std::string >
 

Private Member Functions

 App ()=default
 
auto createGLFWWindow (const AppInfo &appInfo) -> std::expected< bool, std::string >
 

Private Attributes

GLFWwindow_window = nullptr
 

Constructor & Destructor Documentation

◆ ~App()

dodo::core::App::~App ( )
38 {
39 if (_window)
41}
GLFWwindow * _window
Definition App.hpp:20
GLFWAPI void glfwDestroyWindow(GLFWwindow *window)
Destroys the specified window and its context.

References _window, and glfwDestroyWindow().

Here is the call graph for this function:

◆ App() [1/3]

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

◆ App() [2/3]

dodo::core::App::App ( App && other)
noexcept
27 :
28_window(std::exchange(other._window, nullptr))
29{
30
31}

◆ App() [3/3]

dodo::core::App::App ( )
privatedefault

Member Function Documentation

◆ createApp()

auto dodo::core::App::createApp ( const DodoContext & ctx,
const AppInfo & appInfo ) -> std::expected<App, std::string>
static
9 {
10 App app;
11 if (auto result = app.createGLFWWindow(appInfo); !result)
12 return std::unexpected(result.error());
13 return app;
14}

References createGLFWWindow().

Referenced by main().

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

◆ createGLFWWindow()

auto dodo::core::App::createGLFWWindow ( const AppInfo & appInfo) -> std::expected<bool, std::string>
private
16 {
17 const char *errorBuf;
19 _window = glfwCreateWindow(appInfo.width, appInfo.height, appInfo.title.c_str(), appInfo.monitor, nullptr);
20 if (!_window) {
21 glfwGetError(&errorBuf);
22 return std::unexpected(std::format("Failed to create GLFW Window: {}", errorBuf));
23 }
24 return true;
25}
#define GLFW_NO_API
Definition glfw3.h:1140
GLFWAPI int glfwGetError(const char **description)
Returns and clears the last error for the calling thread.
#define GLFW_CLIENT_API
Context client API hint and attribute.
Definition glfw3.h:1031
GLFWAPI void glfwWindowHint(int hint, int value)
Sets the specified window hint to the desired value.
GLFWAPI GLFWwindow * glfwCreateWindow(int width, int height, const char *title, GLFWmonitor *monitor, GLFWwindow *share)
Creates a window and its associated context.

References GLFW_CLIENT_API, GLFW_NO_API, glfwCreateWindow(), glfwGetError(), and glfwWindowHint().

Referenced by createApp().

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

◆ isRunning()

bool dodo::core::App::isRunning ( ) const
inline
41{ return !glfwWindowShouldClose(_window); };
GLFWAPI int glfwWindowShouldClose(GLFWwindow *window)
Checks the close flag of the specified window.

References _window, and glfwWindowShouldClose().

Here is the call graph for this function:

◆ operator=() [1/2]

App & dodo::core::App::operator= ( App && other)
noexcept
33 {
34 _window = std::exchange(other._window, nullptr);
35 return *this;
36}

◆ operator=() [2/2]

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

◆ pollEvents()

void dodo::core::App::pollEvents ( ) const
inline
43{ glfwPollEvents(); };
GLFWAPI void glfwPollEvents(void)
Processes all pending events.

References glfwPollEvents().

Here is the call graph for this function:

Member Data Documentation

◆ _window

GLFWwindow* dodo::core::App::_window = nullptr
private

Referenced by isRunning(), and ~App().


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