Ember
A C++ 20 'game engine' built with SDL3 with wide platform support.
engine_config.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "systems/logging_sys.h"
4 
5 
11 enum class Backend {
20 
26  VK_FORWARD,
27 
31  DIRECTX12,
32 
36  METAL,
37 
41  AUTO
42 };
43 
44 enum class Orientation {
47  PORTRAIT,
49 };
50 
51 enum class AspectRatio {
52  NONE,
53  KEEP,
54  EXPAND,
55 };
56 
57 enum class ViewportMode {
58  VIEWPORT,
59  CANVAS
60 };
61 
67 enum class TextureFiltering {
68  LINEAR,
69  NEAREST
70 };
71 
72 
73 struct Viewport {
74  int width = 320;
75  int height = 180;
76  float scale = 1.0f;
77 
80 
81  bool load(const tinyxml2::XMLElement* root);
82 
83 };
84 
85 struct Environment {
86  glm::vec4 clear_color = {0.0f, 0.0f, 0.0f, 1.0f};
87 
88  bool load(const tinyxml2::XMLElement* root);
89 };
90 
91 struct Application {
92  const char* name = "Window - Ember Engine";
93  const char* version = "1.0";
94  const char* package_name = "br.com.vsaint1.ember_engine"; // identifier
95  const char* icon_path = "res/icon.png";
96  const char* description = "EEngine";
97  int max_fps = 60;
98 
99  bool is_fullscreen = false;
100  bool is_resizable = true;
101  bool is_debug = true;
102 
103  bool load(const tinyxml2::XMLElement* root);
104 };
105 
106 struct Threading {
107  bool is_multithreaded = false;
108  int thread_count = -1; // Default to -1 (auto-detect based on CPU cores)
109 };
110 
114 
115  bool load(const tinyxml2::XMLElement* root);
116 
117  [[nodiscard]] const char* get_backend_str() const;
118 
119 };
120 
121 enum class WindowMode {
122  WINDOWED,
123  MAXIMIZED,
124  MINIMIZED,
125  FULLSCREEN
126 };
127 
128 struct Window {
129  glm::ivec2 size = glm::ivec2(1280,720);
130 
132 
133  float dpi_scale = 1.0f;
134 
135  bool load (const tinyxml2::XMLElement* root);
136 };
137 
138 struct EngineConfig {
139 
141 
143 
144  bool load();
145 
146  const char* get_orientation_str() const;
147 
149 
150  Threading get_threading() const;
151 
153 
155 
156  Viewport get_viewport() const;
157 
158  Window get_window() const;
159 
160  bool is_vsync() const;
161 
162  void set_vsync(bool enabled);
163 
164 private:
165 
166  Application _app;
167 
168  Environment _environment;
169 
170  Viewport _viewport;
171 
172  RendererDevice _renderer_device;
173 
174  Threading _threading;
175 
176  Window _window;
177 
178  bool _is_vsync_enabled = true;
179 
180  tinyxml2::XMLDocument _doc = {};
181 };
@ NONE
No command.
TextureFiltering
Texture filtering modes.
Definition: engine_config.h:67
@ LINEAR
Smooth filtering.
@ NEAREST
Pixelated filtering.
ViewportMode
Definition: engine_config.h:57
WindowMode
Definition: engine_config.h:121
Orientation
Definition: engine_config.h:44
@ PORTRAIT_UPSIDE_DOWN
AspectRatio
Definition: engine_config.h:51
Backend
Supported rendering backends for the engine.
Definition: engine_config.h:11
@ GL_COMPATIBILITY
OpenGL-based compatibility profile.
@ METAL
Metal backend (macOS + iOS).
@ VK_FORWARD
Vulkan-based high-performance profile.
@ DIRECTX12
DirectX 12 backend (Windows + Xbox).
@ AUTO
Automatically choose the best backend for the platform.
Definition: engine_config.h:91
bool is_debug
Definition: engine_config.h:101
const char * name
Definition: engine_config.h:92
const char * version
Definition: engine_config.h:93
const char * description
Definition: engine_config.h:96
int max_fps
Definition: engine_config.h:97
bool is_fullscreen
Definition: engine_config.h:99
bool load(const tinyxml2::XMLElement *root)
Definition: engine_config.cpp:83
const char * package_name
Definition: engine_config.h:94
bool is_resizable
Definition: engine_config.h:100
const char * icon_path
Definition: engine_config.h:95
Definition: engine_config.h:138
bool is_vsync() const
Definition: engine_config.cpp:316
Orientation orientation
Definition: engine_config.h:140
RendererDevice get_renderer_device() const
Definition: engine_config.cpp:292
void set_vsync(bool enabled)
Definition: engine_config.cpp:320
const char * get_orientation_str() const
Definition: engine_config.cpp:148
Threading get_threading() const
Definition: engine_config.cpp:296
Application get_application() const
Definition: engine_config.cpp:300
TextureFiltering texture_filtering
Definition: engine_config.h:142
Environment get_environment() const
Definition: engine_config.cpp:304
Viewport get_viewport() const
Definition: engine_config.cpp:308
Window get_window() const
Definition: engine_config.cpp:312
bool load()
Definition: engine_config.cpp:229
Definition: engine_config.h:85
glm::vec4 clear_color
Definition: engine_config.h:86
bool load(const tinyxml2::XMLElement *root)
Definition: engine_config.cpp:54
Definition: engine_config.h:111
bool load(const tinyxml2::XMLElement *root)
Definition: engine_config.cpp:163
TextureFiltering texture_filtering
Definition: engine_config.h:113
const char * get_backend_str() const
Definition: engine_config.cpp:206
Backend backend
Definition: engine_config.h:112
Definition: engine_config.h:106
int thread_count
Definition: engine_config.h:108
bool is_multithreaded
Definition: engine_config.h:107
Definition: engine_config.h:73
int width
Definition: engine_config.h:74
AspectRatio aspect_ratio
Definition: engine_config.h:79
bool load(const tinyxml2::XMLElement *root)
Definition: engine_config.cpp:6
float scale
Definition: engine_config.h:76
int height
Definition: engine_config.h:75
ViewportMode mode
Definition: engine_config.h:78
Definition: engine_config.h:128
float dpi_scale
Definition: engine_config.h:133
bool load(const tinyxml2::XMLElement *root)
Definition: engine_config.cpp:224
WindowMode window_mode
Definition: engine_config.h:131
glm::ivec2 size
Definition: engine_config.h:129