Properly link flecs library

This commit is contained in:
2023-11-09 11:38:29 +01:00
parent dc585396c3
commit 8edcf9305c
1392 changed files with 390081 additions and 164 deletions

View File

@@ -0,0 +1,16 @@
#ifndef BASICS_BITMASK_H
#define BASICS_BITMASK_H
/* This generated file contains includes for project dependencies */
#include "basics_bitmask/bake_config.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,24 @@
/*
)
(.)
.|.
| |
_.--| |--._
.-'; ;`-'& ; `&.
\ & ; & &_/
|"""---...---"""|
\ | | | | | | | /
`---.|.|.|.---'
* 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 BASICS_BITMASK_BAKE_CONFIG_H
#define BASICS_BITMASK_BAKE_CONFIG_H
/* Headers of public dependencies */
#include <flecs.h>
#endif

View File

@@ -0,0 +1,10 @@
{
"id": "basics_bitmask",
"type": "application",
"value": {
"use": [
"flecs"
],
"public": false
}
}

View File

@@ -0,0 +1,48 @@
#include <basics_bitmask.h>
#include <stdio.h>
typedef uint32_t Toppings;
static const uint32_t Bacon = 0x1;
static const uint32_t Lettuce = 0x2;
static const uint32_t Tomato = 0x4;
typedef struct {
Toppings toppings;
} Sandwich;
int main(int argc, char *argv[]) {
ecs_world_t *ecs = ecs_init_w_args(argc, argv);
// Register component as usual
ECS_COMPONENT(ecs, Toppings);
ECS_COMPONENT(ecs, Sandwich);
// Add reflection data to components
ecs_bitmask(ecs,{
.entity = ecs_id(Toppings), // Make sure to use existing id
.constants = {
{ .name = "Bacon", .value = Bacon },
{ .name = "Lettuce", .value = Lettuce },
{ .name = "Tomato", .value = Tomato }
}
});
ecs_struct(ecs, {
.entity = ecs_id(Sandwich), // Make sure to use existing id
.members = {
{ .name = "toppings", .type = ecs_id(Toppings) }
}
});
// Create entity with Position as usual
ecs_entity_t ent = ecs_new_id(ecs);
ecs_set(ecs, ent, Sandwich, {Bacon | Lettuce});
// Convert position component to flecs expression string
const Sandwich *ptr = ecs_get(ecs, ent, Sandwich);
char *str = ecs_ptr_to_expr(ecs, ecs_id(Sandwich), ptr);
printf("%s\n", str); // {toppings: Bacon|Lettuce}
ecs_os_free(str);
ecs_fini(ecs);
}