Dodo 0.1
Template for CPP projects
Loading...
Searching...
No Matches
App.hpp
Go to the documentation of this file.
1//
2// Created by nicol on 19/02/2026.
3//
4
5#ifndef DODO_CORE_HPP
6#define DODO_CORE_HPP
7
8#include <expected>
9#include <format>
10#include <string>
11#include <utility>
12
13#include "DodoContext.hpp"
14#include "GLFW/glfw3.h"
15
16namespace dodo::core {
17
18class App {
19 private:
20 GLFWwindow *_window = nullptr;
21 public:
22 struct AppInfo {
23 size_t width;
24 size_t height;
25 std::string title;
26 GLFWmonitor *monitor = nullptr;
27 };
28
29 ~App();
30
31 App(const App &other) = delete;
32
33 App &operator=(const App &other) = delete;
34
35 App(App && other) noexcept;
36
37 App &operator=(App && other) noexcept;
38
39 static auto createApp(const DodoContext &ctx, const AppInfo &appInfo) -> std::expected<App, std::string>;
40
41 bool isRunning() const { return !glfwWindowShouldClose(_window); };
42
43 void pollEvents() const { glfwPollEvents(); };
44 private:
45 App() = default;
46
47 auto createGLFWWindow(const AppInfo &appInfo) -> std::expected<bool, std::string>;
48};
49
50};
51
52#endif // DODO_CORE_HPP
Definition App.hpp:18
App & operator=(const App &other)=delete
bool isRunning() const
Definition App.hpp:41
~App()
Definition App.cpp:38
App(const App &other)=delete
static auto createApp(const DodoContext &ctx, const AppInfo &appInfo) -> std::expected< App, std::string >
Definition App.cpp:9
void pollEvents() const
Definition App.hpp:43
auto createGLFWWindow(const AppInfo &appInfo) -> std::expected< bool, std::string >
Definition App.cpp:16
GLFWwindow * _window
Definition App.hpp:20
Definition DodoContext.hpp:15
The header of the GLFW 3 API.
struct GLFWmonitor GLFWmonitor
Opaque monitor object.
Definition glfw3.h:1391
struct GLFWwindow GLFWwindow
Opaque window object.
Definition glfw3.h:1403
GLFWAPI void glfwPollEvents(void)
Processes all pending events.
GLFWAPI int glfwWindowShouldClose(GLFWwindow *window)
Checks the close flag of the specified window.
Definition App.cpp:7
Definition App.hpp:22
GLFWmonitor * monitor
Definition App.hpp:26
size_t width
Definition App.hpp:23
size_t height
Definition App.hpp:24
std::string title
Definition App.hpp:25