Properly link flecs library
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
#ifndef BASICS_ENUM_H
|
||||
#define BASICS_ENUM_H
|
||||
|
||||
/* This generated file contains includes for project dependencies */
|
||||
#include "basics_enum/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 BASICS_ENUM_BAKE_CONFIG_H
|
||||
#define BASICS_ENUM_BAKE_CONFIG_H
|
||||
|
||||
/* Headers of public dependencies */
|
||||
#include <flecs.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"id": "basics_enum",
|
||||
"type": "application",
|
||||
"value": {
|
||||
"use": [
|
||||
"flecs"
|
||||
],
|
||||
"language": "c++",
|
||||
"public": false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#include <basics_enum.h>
|
||||
#include <iostream>
|
||||
|
||||
enum Color {
|
||||
Red,
|
||||
Green,
|
||||
Blue
|
||||
};
|
||||
|
||||
struct TypeWithEnum {
|
||||
Color color;
|
||||
};
|
||||
|
||||
int main(int, char *[]) {
|
||||
flecs::world ecs;
|
||||
|
||||
// Register components with reflection data
|
||||
ecs.component<Color>()
|
||||
.constant("Red", Red)
|
||||
.constant("Green", Green)
|
||||
.constant("Blue", Blue);
|
||||
|
||||
ecs.component<TypeWithEnum>()
|
||||
.member<Color>("color");
|
||||
|
||||
// Create entity with Position as usual
|
||||
flecs::entity e = ecs.entity()
|
||||
.set<TypeWithEnum>({Green});
|
||||
|
||||
// Convert position component to flecs expression string
|
||||
const TypeWithEnum *ptr = e.get<TypeWithEnum>();
|
||||
std::cout << ecs.to_expr(ptr).c_str() << "\n"; // {color: Green}
|
||||
}
|
||||
Reference in New Issue
Block a user