-
Notifications
You must be signed in to change notification settings - Fork 8
/
flecs_components_graphics.h
248 lines (205 loc) · 5.61 KB
/
flecs_components_graphics.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
// Comment out this line when using as DLL
#define flecs_components_graphics_STATIC
#ifndef FLECS_COMPONENTS_GRAPHICS_H
#define FLECS_COMPONENTS_GRAPHICS_H
/*
)
(.)
.|.
| |
_.--| |--._
.-'; ;`-'& ; `&.
\ & ; & &_/
|"""---...---"""|
\ | | | | | | | /
`---.|.|.|.---'
* This file is generated by bake.lang.c for your convenience. Headers of
* dependencies will automatically show up in this file. Include bake_config.h
* in your main project file. Do not edit! */
#ifndef FLECS_COMPONENTS_GRAPHICS_BAKE_CONFIG_H
#define FLECS_COMPONENTS_GRAPHICS_BAKE_CONFIG_H
/* Headers of public dependencies */
#include "flecs.h"
#include "flecs_components_cglm.h"
/* Convenience macro for exporting symbols */
#ifndef flecs_components_graphics_STATIC
#if defined(flecs_components_graphics_EXPORTS) && (defined(_MSC_VER) || defined(__MINGW32__))
#define FLECS_COMPONENTS_GRAPHICS_API __declspec(dllexport)
#elif defined(flecs_components_graphics_EXPORTS)
#define FLECS_COMPONENTS_GRAPHICS_API __attribute__((__visibility__("default")))
#elif defined(_MSC_VER)
#define FLECS_COMPONENTS_GRAPHICS_API __declspec(dllimport)
#else
#define FLECS_COMPONENTS_GRAPHICS_API
#endif
#else
#define FLECS_COMPONENTS_GRAPHICS_API
#endif
#endif
// Reflection system boilerplate
#undef ECS_META_IMPL
#ifndef FLECS_COMPONENTS_GRAPHICS_IMPL
#define ECS_META_IMPL EXTERN // Ensure meta symbols are only defined once
#endif
#ifdef __cplusplus
extern "C" {
#endif
FLECS_COMPONENTS_GRAPHICS_API
ECS_STRUCT(EcsCamera, {
vec3 position;
vec3 lookat;
vec3 up;
float fov;
float near_;
float far_;
bool ortho;
});
FLECS_COMPONENTS_GRAPHICS_API
ECS_STRUCT(EcsDirectionalLight, {
vec3 position;
vec3 direction;
vec3 color;
float intensity;
});
FLECS_COMPONENTS_GRAPHICS_API
ECS_STRUCT(EcsPointLight, {
vec3 color;
float distance;
float intensity;
});
FLECS_COMPONENTS_GRAPHICS_API
ECS_STRUCT(EcsLookAt, {
float x;
float y;
float z;
});
FLECS_COMPONENTS_GRAPHICS_API
ECS_STRUCT(EcsRgb, {
float r;
float g;
float b;
});
typedef EcsRgb ecs_rgb_t;
FLECS_COMPONENTS_GRAPHICS_API
ECS_STRUCT(EcsOpacity, {
float value;
});
FLECS_COMPONENTS_GRAPHICS_API
ECS_STRUCT(EcsSpecular, {
float specular_power;
float shininess;
});
FLECS_COMPONENTS_GRAPHICS_API
ECS_STRUCT(EcsEmissive, {
float value;
});
FLECS_COMPONENTS_GRAPHICS_API
ECS_STRUCT(EcsLightIntensity, {
float value;
});
FLECS_COMPONENTS_GRAPHICS_API
ECS_STRUCT(EcsAtmosphere, {
float intensity;
float planet_radius;
float atmosphere_radius;
vec3 rayleigh_coef;
float mie_coef;
float rayleigh_scale_height;
float mie_scale_height;
float mie_scatter_dir;
});
FLECS_COMPONENTS_GRAPHICS_API
extern ECS_TAG_DECLARE(EcsSun);
FLECS_COMPONENTS_GRAPHICS_API
void FlecsComponentsGraphicsImport(
ecs_world_t *world);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
#ifndef FLECS_NO_CPP
namespace flecs {
namespace components {
class graphics {
public:
struct rgb_t : ecs_rgb_t {
operator float*() {
return reinterpret_cast<float*>(this);
}
};
struct Camera : EcsCamera {
Camera() {
this->set_position(0, 0, 0);
this->set_lookat(0, 1, 1);
this->set_up(0, -1, 0);
this->set_fov(30);
this->near_ = 0.1f;
this->far_ = 100;
this->ortho = false;
}
void set_position(float x, float y, float z) {
this->position[0] = x;
this->position[1] = y;
this->position[2] = z;
}
void set_lookat(float x, float y, float z) {
this->lookat[0] = x;
this->lookat[1] = y;
this->lookat[2] = z;
}
void set_up(float x, float y, float z) {
this->up[0] = x;
this->up[1] = y;
this->up[2] = z;
}
void set_fov(float value) {
this->fov = value;
}
};
struct DirectionalLight : EcsDirectionalLight {
DirectionalLight() {
this->set_position(0, 0, 0);
this->set_direction(0, 1, 1);
this->set_color(1, 1, 1);
}
void set_position(float x, float y, float z) {
this->position[0] = x;
this->position[1] = y;
this->position[2] = z;
}
void set_direction(float x, float y, float z) {
this->direction[0] = x;
this->direction[1] = y;
this->direction[2] = z;
}
void set_color(float r, float g, float b) {
this->color[0] = r;
this->color[1] = g;
this->color[2] = b;
}
};
using Color = EcsRgb;
using Opacity = EcsOpacity;
using Specular = EcsSpecular;
using Emissive = EcsEmissive;
using Atmosphere = EcsAtmosphere;
using PointLight = EcsPointLight;
graphics(flecs::world& ecs) {
// Load module contents
FlecsComponentsGraphicsImport(ecs);
// Bind C++ types with module contents
ecs.module<flecs::components::graphics>();
ecs.component<Camera>();
ecs.component<DirectionalLight>();
ecs.component<PointLight>();
ecs.component<Color>();
ecs.component<Opacity>();
ecs.component<Specular>();
ecs.component<Emissive>();
}
};
}
}
#endif
#endif
#endif