Properly link flecs library
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
#ifndef NESTED_SET_MEMBER_H
|
||||
#define NESTED_SET_MEMBER_H
|
||||
|
||||
/* This generated file contains includes for project dependencies */
|
||||
#include "nested_set_member/bake_config.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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 NESTED_SET_MEMBER_BAKE_CONFIG_H
|
||||
#define NESTED_SET_MEMBER_BAKE_CONFIG_H
|
||||
|
||||
/* Headers of public dependencies */
|
||||
#include <flecs.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"id": "nested_set_member",
|
||||
"type": "application",
|
||||
"value": {
|
||||
"use": [
|
||||
"flecs"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
#include <nested_set_member.h>
|
||||
#include <stdio.h>
|
||||
|
||||
ECS_STRUCT(Point, {
|
||||
float x;
|
||||
float y;
|
||||
});
|
||||
|
||||
ECS_STRUCT(Line, {
|
||||
Point start;
|
||||
Point stop;
|
||||
});
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
ecs_world_t *ecs = ecs_init_w_args(argc, argv);
|
||||
|
||||
ECS_META_COMPONENT(ecs, Point);
|
||||
ECS_META_COMPONENT(ecs, Line);
|
||||
|
||||
ecs_entity_t ent = ecs_new_id(ecs);
|
||||
Line *ptr = ecs_get_mut(ecs, ent, Line);
|
||||
|
||||
ecs_meta_cursor_t cur = ecs_meta_cursor(ecs, ecs_id(Line), ptr);
|
||||
ecs_meta_push(&cur); // {
|
||||
ecs_meta_member(&cur, "start"); // start:
|
||||
ecs_meta_push(&cur); // {
|
||||
ecs_meta_member(&cur, "x"); // x:
|
||||
ecs_meta_set_float(&cur, 10); // 10
|
||||
ecs_meta_member(&cur, "y"); // y:
|
||||
ecs_meta_set_float(&cur, 20); // 20
|
||||
ecs_meta_pop(&cur); // }
|
||||
ecs_meta_member(&cur, "stop"); // stop:
|
||||
ecs_meta_push(&cur); // {
|
||||
ecs_meta_member(&cur, "x"); // x:
|
||||
ecs_meta_set_float(&cur, 30); // 30
|
||||
ecs_meta_member(&cur, "y"); // y:
|
||||
ecs_meta_set_float(&cur, 40); // 40
|
||||
ecs_meta_pop(&cur); // }
|
||||
ecs_meta_pop(&cur); // }
|
||||
|
||||
char *str = ecs_ptr_to_expr(ecs, ecs_id(Line), ptr);
|
||||
printf("%s\n", str);
|
||||
ecs_os_free(str);
|
||||
|
||||
// {start: {x: 10.00, y: 20.00}, stop: {x: 30.00, y: 40.00}}
|
||||
|
||||
return ecs_fini(ecs);
|
||||
}
|
||||
Reference in New Issue
Block a user