Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches
config.h
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2025-2026 Manuel Osorio
3#pragma once
4#include "log.h"
5
6#include <filesystem>
7#include <string>
8
9namespace Flint {
16 enum class GRAPHICS_BACKEND {
17 AUTO,
18 VULKAN,
19 METAL,
20 D3D12
21 };
22
23 enum class GRAPHICS_PRESENT_MODE {
24 IMMEDIATE,
25 VSYNC,
26 MAILBOX
27 };
28
34 inline GRAPHICS_BACKEND resolveBackend(GRAPHICS_BACKEND backend) {
35 if (backend != GRAPHICS_BACKEND::AUTO) {
36 return backend;
37 }
38
39#if defined(__APPLE__)
40 return GRAPHICS_BACKEND::METAL;
41#elif defined(_WIN32) || defined(__linux__)
42 return GRAPHICS_BACKEND::VULKAN;
43#else
44 return GRAPHICS_BACKEND::VULKAN;
45#endif
46 }
47
54 inline const char *getGpuDriverHint(GRAPHICS_BACKEND backend) {
55 switch (backend) {
56 case GRAPHICS_BACKEND::VULKAN:
57 {
58 return "VULKAN";
59 }
60 case GRAPHICS_BACKEND::METAL:
61 {
62 return "METAL";
63 }
64 case GRAPHICS_BACKEND::D3D12:
65 {
66 return "direct3d12";
67 }
68 case GRAPHICS_BACKEND::AUTO:
69 default:
70 {
71 return nullptr;
72 }
73 }
74 }
75
80 std::string appName = "Flint App";
81 std::string appVersion = "0.1.0";
82 std::string appIdentifier = "com.example.flint-app";
84 std::string windowTitle = "Flint";
85 int width = 1280;
86 int height = 720;
88 bool resizable = true;
89 bool fullscreen = false;
91 std::filesystem::path assetRoot = "assets";
92 };
93
97 struct EngineConfig {
98 GRAPHICS_BACKEND backend = GRAPHICS_BACKEND::AUTO;
99 GRAPHICS_PRESENT_MODE presentMode =
100 GRAPHICS_PRESENT_MODE::VSYNC;
102 float maxFPS = 0;
104 bool enableAudio = true;
105 bool enableGamepads = true;
106 bool enableHaptics = true;
107 bool verboseSdlLogging = false;
108 bool initTrueTypeFont = true;
109 bool embedDefaultFont = true;
111#ifdef NDEBUG
112 bool enableAssetHotReload = false;
113#else
114 bool enableAssetHotReload = true;
115#endif
116 };
117
119#ifdef NDEBUG
120 LOG_LEVEL engineLevel = LOG_LEVEL::Warn;
121 LOG_LEVEL applicationLevel = LOG_LEVEL::Info;
122#else
123 LOG_LEVEL engineLevel = LOG_LEVEL::Debug;
124 LOG_LEVEL applicationLevel = LOG_LEVEL::Debug;
125#endif
126 };
127
136}
std::string appName
Definition config.h:80
std::string appVersion
Definition config.h:81
std::filesystem::path assetRoot
Definition config.h:91
std::string appIdentifier
Definition config.h:82
std::string windowTitle
Definition config.h:84
User-facing metadata and window defaults for a Flint-powered application.
Definition config.h:79
GRAPHICS_BACKEND backend
Definition config.h:98
GRAPHICS_PRESENT_MODE presentMode
Definition config.h:99
Engine initialization toggles that control runtime systems and GPU behavior.
Definition config.h:97
ApplicationConfig app
Definition config.h:132
EngineConfig engine
Definition config.h:133
Aggregate configuration passed to the engine bootstrap code.
Definition config.h:131