Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches
game-module.h
1
// SPDX-License-Identifier: MIT
2
// SPDX-FileCopyrightText: 2025-2026 Manuel Osorio
3
#pragma once
4
5
#include "state-ops.h"
6
7
#include <array>
8
#include <cstddef>
9
#include <cstdint>
10
11
namespace
Flint {
12
13
constexpr
std::uint32_t GAME_MODULE_ABI_VERSION = 4;
14
15
struct
GameModule
{
16
std::uint32_t abiVersion;
17
const
StateOps
*stateOps;
18
std::size_t stateOpsCount;
19
};
20
21
template
<
typename
... States>
22
struct
GameModuleStorage
{
23
std::array<
StateOps
,
sizeof
...(States)> stateOperations{makeStateOps<States>()...};
24
25
GameModule
module{
26
.abiVersion = GAME_MODULE_ABI_VERSION,
27
.stateOps = stateOperations.data(),
28
.stateOpsCount = stateOperations.size(),
29
};
30
};
31
}
32
33
#ifdef _WIN32
34
#define FLINT_GAME_MODULE_EXPORT __declspec(dllexport)
35
#elif defined(__GNUC__) || defined(__clang__)
36
#define FLINT_GAME_MODULE_EXPORT __attribute__((visibility("default")))
37
#else
38
#define FLINT_GAME_MODULE_EXPORT
39
#endif
40
41
#define FLINT_DEFINE_GAME_MODULE(...) \
42
extern "C" { \
43
FLINT_GAME_MODULE_EXPORT const ::Flint::GameModule *flintGetGameModule() { \
44
static const ::Flint::GameModuleStorage<__VA_ARGS__> storage{}; \
45
return &storage.module; \
46
} \
47
}
Flint::GameModuleStorage
Definition
game-module.h:22
Flint::GameModule
Definition
game-module.h:15
Flint::StateOps
Definition
state-ops.h:36
include
flint
core
game-module.h
Generated by
1.12.0