Flecs: include/flecs/addons/app.h Source File
Description: A fast entity component system (ECS) for C & C++

| Flecs v4.1 A fast entity component system (ECS) for C & C++

Loading...
Searching...
No Matches
app.h
Go to the documentation of this file.
1
10
11#ifdef FLECS_APP
12
13#ifndef FLECS_PIPELINE
14#define FLECS_PIPELINE
15#endif
16
17#ifndef FLECS_APP_H
18#define FLECS_APP_H
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
31
33 typedef int(*ecs_app_init_action_t)(
34 ecs_world_t *world);
35
37 typedef struct ecs_app_desc_t {
38 ecs_ftime_t target_fps;
39 ecs_ftime_t delta_time;
40 int32_t threads;
41 int32_t frames;
42 bool enable_rest;
43 bool enable_stats;
44 uint16_t port;
45
46 ecs_app_init_action_t init;
48
49 void *ctx;
50} ecs_app_desc_t;
51
53 typedef int(*ecs_app_run_action_t)(
54 ecs_world_t *world,
55 ecs_app_desc_t *desc);
56
58 typedef int(*ecs_app_frame_action_t)(
59 ecs_world_t *world,
60 const ecs_app_desc_t *desc);
61
74FLECS_API
75 int ecs_app_run(
76 ecs_world_t *world,
77 ecs_app_desc_t *desc);
78
87FLECS_API
88 int ecs_app_run_frame(
89 ecs_world_t *world,
90 const ecs_app_desc_t *desc);
91
98FLECS_API
99 int ecs_app_set_run_action(
100 ecs_app_run_action_t callback);
101
108FLECS_API
109 int ecs_app_set_frame_action(
110 ecs_app_frame_action_t callback);
111
113
114#ifdef __cplusplus
115}
116#endif
117
118#endif
119
120#endif // FLECS_APP
ecs_app_init_action_t
int(* ecs_app_init_action_t)(ecs_world_t *world)
Callback type for init action.
Definition app.h:33
ecs_app_frame_action_t
int(* ecs_app_frame_action_t)(ecs_world_t *world, const ecs_app_desc_t *desc)
Callback type for frame action.
Definition app.h:58
ecs_app_run_action_t
int(* ecs_app_run_action_t)(ecs_world_t *world, ecs_app_desc_t *desc)
Callback type for run action.
Definition app.h:53
ecs_app_run
FLECS_API int ecs_app_run(ecs_world_t *world, ecs_app_desc_t *desc)
Run application.
ecs_app_run_frame
FLECS_API int ecs_app_run_frame(ecs_world_t *world, const ecs_app_desc_t *desc)
Default frame callback.
ecs_app_set_run_action
FLECS_API int ecs_app_set_run_action(ecs_app_run_action_t callback)
Set custom run action.
ecs_app_set_frame_action
FLECS_API int ecs_app_set_frame_action(ecs_app_frame_action_t callback)
Set custom frame action.
ecs_world_t
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:425
ecs_ftime_t
#define ecs_ftime_t
Customizable precision for scalar time values.
Definition flecs.h:59
ecs_app_desc_t
Used with ecs_app_run().
Definition app.h:37
ecs_app_desc_t::port
uint16_t port
HTTP port used by REST API.
Definition app.h:44
ecs_app_desc_t::enable_stats
bool enable_stats
Periodically collects statistics.
Definition app.h:43
ecs_app_desc_t::target_fps
ecs_ftime_t target_fps
Target FPS.
Definition app.h:38
ecs_app_desc_t::delta_time
ecs_ftime_t delta_time
Frame time increment (0 for measured values).
Definition app.h:39
ecs_app_desc_t::init
ecs_app_init_action_t init
If set, the function is run before starting the main loop.
Definition app.h:46
ecs_app_desc_t::frames
int32_t frames
Number of frames to run (0 for infinite).
Definition app.h:41
ecs_app_desc_t::ctx
void * ctx
Reserved for custom run and frame actions.
Definition app.h:49
ecs_app_desc_t::enable_rest
bool enable_rest
Enables ECS access over HTTP, necessary for the explorer.
Definition app.h:42
ecs_app_desc_t::threads
int32_t threads
Number of threads.
Definition app.h:40