Skip to content

Commit

Permalink
Move build instructions from README to Quickstart, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed Jan 17, 2023
1 parent 2b0a2d8 commit 2e77e3e
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 145 deletions.
94 changes: 14 additions & 80 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
![flecs](docs/img/logo.png)

## Introduction
[![Version](https://img.shields.io/github/v/release/sandermertens/flecs?include_prereleases&style=for-the-badge)](https://github.com/SanderMertens/flecs/releases)
[![MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge)](/LICENSE)
[![Documentation](https://img.shields.io/badge/docs-flecs-blue?style=for-the-badge&color=blue)](https://www.flecs.dev/flecs/md_docs_Docs.html)
Expand All @@ -13,8 +12,7 @@ Flecs is a fast and lightweight Entity Component System that lets you build game
- Modern type-safe [C++11 API](https://www.flecs.dev/flecs/group__cpp.html) that doesn't use STL containers
- First open source ECS with full support for [Entity Relationships](https://www.flecs.dev/flecs/md_docs_Relationships.html)!
- Fast native support for [hierarchies](https://www.flecs.dev/flecs/md_docs_Relationships.html#autotoc_md277) and [prefabs](https://www.flecs.dev/flecs/md_docs_Relationships.html#autotoc_md275)
- Minimal ECS core with optional [addons](#addons)
- Entire codebase builds in less than 5 seconds
- Code base that builds in less than 5 seconds
- Runs [in the browser](https://flecs.dev/city) without modifications with emscripten
- Cache friendly [archetype/SoA storage](https://ajmmertens.medium.com/building-an-ecs-2-archetypes-and-vectorization-fe21690805f9) that can process millions of entities every frame
- Supports entities with hundreds of components and applications with tens of thousands of archetypes
Expand All @@ -28,38 +26,25 @@ Flecs is a fast and lightweight Entity Component System that lets you build game
- [Statistics addon](https://www.flecs.dev/flecs/group__c__addons__stats.html) for profiling ECS performance
- A web-based dashboard ([demo](https://flecs.dev/explorer), [code](https://github.com/flecs-hub/explorer)) for inspecting entities, running ECS queries and monitoring games:

[![Dashboard image](docs/img/explorer.png)](https://flecs.dev/explorer)
[![Flecs Explorer](docs/img/explorer.png)](https://flecs.dev/explorer)

## What is an Entity Component System?
ECS is a new way of organizing code and data that lets you build games that are larger, more complex and are easier to extend.
To support the project, give it a star 🌟 !

Something is called an ECS when it:
## What is an Entity Component System?
ECS is a way of organizing code and data that lets you build games that are larger, more complex and are easier to extend. Something is called an ECS when it:
- Has _entities_ that uniquely identify objects in a game
- Has _components_ which are datatypes that can be added to entities
- Has _systems_ which are functions that run for all entities matching a component _query_

For example, a game has a `Move` _system_ that has a _query_ with two _components_, `Position, Velocity`. When the system is ran it is dynamically matched with all _entities_ that have at least these two components.

For more info on ECS, check the [ECS FAQ](https://github.com/SanderMertens/ecs-faq)!

## Getting Started
To use Flecs, add the [flecs.c](https://raw.githubusercontent.com/SanderMertens/flecs/master/flecs.c) and [flecs.h](https://raw.githubusercontent.com/SanderMertens/flecs/master/flecs.h) files to your project. When importing the files into a C++ project, make sure to compile [flecs.c](https://raw.githubusercontent.com/SanderMertens/flecs/master/flecs.c) as C code (for example by using `gcc` and `clang` instead of `g++` and `clang++`).

The ECS core compiles as C99 code and can be compiled with `-std=c99`. Some addons that are enabled by default require functionality that is not part of C99 for things like measuring time and HTTP sockets (for using the explorer), which can throw compiler errors. To fix these, either compile the code with `-std=gnu99` or add `-D_XOPEN_SOURCE=600`.

Flecs can also be built as a standalone library, by using the cmake, meson, bazel or [bake](https://github.com/SanderMertens/bake) build files. If you are using a custom build file to compile Flecs as a library, make sure to define `flecs_EXPORTS`, for example by adding `-Dflecs_EXPORTS` to the compiler command.
For more information, check the [ECS FAQ](https://github.com/SanderMertens/ecs-faq)!

If you want to use the [flecs.c](https://raw.githubusercontent.com/SanderMertens/flecs/master/flecs.c) and [flecs.h](https://raw.githubusercontent.com/SanderMertens/flecs/master/flecs.h) files to build a standalone library, make sure to remove this line from the top of the [flecs.h](https://raw.githubusercontent.com/SanderMertens/flecs/master/flecs.h) file:
## Documentation
- [Quickstart](https://www.flecs.dev/flecs/md_docs_Quickstart.html)
- [Examples](https://github.com/SanderMertens/flecs/tree/master/examples)
- [All Documentation](https://www.flecs.dev/flecs/md_docs_Docs.html)

```c
#define flecs_STATIC
```

If you are building on Windows with mingw/gcc/clang, add `-lWs2_32` to the linker command (only needed for the HTTP/REST addons).

Make sure to compile C++ files as at least C++11 by adding `-std=c++0x` or higher to gcc/clang compile commands.

By default Flecs includes many features that may not be useful for every project. Builds can be customized to minimize the overhead of the library. See the [Addons](#addons) section for more information on customized builds.
## Performance
For a list of regularly tracked benchmarks, see the [ECS Benchmark](https://github.com/SanderMertens/ecs_benchmark) project.

## Show me the code!
C99 example:
Expand Down Expand Up @@ -95,6 +80,7 @@ int main(int argc, char *argv[]) {
```
Same example in C++11:
```cpp
struct Position {
float x, y;
Expand Down Expand Up @@ -160,9 +146,6 @@ https://www.flecs.dev/city ([repository](https://github.com/flecs-hub/city))

## Resources

### Documentation
- [Flecs Documentation](https://www.flecs.dev/flecs/index.html)

### Resources provided by the community :heart:
- [Unreal Minimum Viable Flecs Project](https://github.com/PreyK/Unreal-Minimum-Viable-Flecs)
- [Bgfx/Imgui module](https://github.com/flecs-hub/flecs-systems-bgfx/tree/bgfx_imgui)
Expand All @@ -176,56 +159,12 @@ https://www.flecs.dev/city ([repository](https://github.com/flecs-hub/city))
- [Flecs + gunslinger example](https://github.com/MrFrenik/gs_examples/blob/main/ex_demos/flecs/source/main.c)
- [Flecs based 3D game engine with editor](https://bit.ly/3T9cc1o)

### Flecs links
### Flecs around the web
- [Discord](https://discord.gg/BEzP5Rgrrp)
- [Medium](https://ajmmertens.medium.com)
- [ECS FAQ](https://github.com/SanderMertens/ecs-faq)
- [Twitter](https://twitter.com/ajmmertens)
- [Reddit](https://www.reddit.com/r/flecs)

## Addons
Flecs has a modular architecture that makes it easy to only build the features you really need. By default all addons are built. To customize a build, first define `FLECS_CUSTOM_BUILD`, then add defines for the addons you need. For example:

```c
#define FLECS_CUSTOM_BUILD // Don't build all addons
#define FLECS_SYSTEM // Build FLECS_SYSTEM
```
Additionally, you can also specify addons to exclude from a build by adding `NO` to the define:
```c
#define FLECS_NO_LOG
```

The following addons can be configured:

Addon | Description | Define |
--------------|--------------------------------------------------|---------------------|
[Cpp](/flecs/group__cpp.html) | C++11 API | FLECS_CPP |
[Module](/flecs/group__c__addons__module.html) | Organize game logic into reusable modules | FLECS_MODULE |
[System](flecs/group__c__addons__system.html) | Create & run systems | FLECS_SYSTEM |
[Pipeline](/flecs/group__c__addons__pipeline.html) | Automatically schedule & multithread systems | FLECS_PIPELINE |
[Timer](/flecs/group__c__addons__timer.html) | Run systems at time intervals or at a rate | FLECS_TIMER |
[Meta](/flecs/group__c__addons__meta.html) | Flecs reflection system | FLECS_META |
[Meta_C](/flecs/group__c__addons__meta_c.html) | (C) Utilities for auto-inserting reflection data | FLECS_META_C |
[Units](/flecs/group__c__addons__units.html) | Builtin unit types | FLECS_UNITS |
[Expr](/flecs/group__c__addons__expr.html) | String format optimized for ECS data | FLECS_EXPR |
[JSON](/flecs/group__c__addons__json.html) | JSON format | FLECS_JSON |
[Doc](/flecs/group__c__addons__doc.html) | Add documentation to components, systems & more | FLECS_DOC |
[Coredoc](/flecs/group__c__addons__coredoc.html) | Documentation for builtin components & modules | FLECS_COREDOC |
[Http](/flecs/group__c__addons__http.html) | Tiny HTTP server for processing simple requests | FLECS_HTTP |
[Rest](/flecs/group__c__addons__rest.html) | REST API for showing entities in the browser | FLECS_REST |
[Parser](/flecs/group__c__addons__parser.html) | Create entities & queries from strings | FLECS_PARSER |
[Plecs](/flecs/group__c__addons__plecs.html) | Small utility language for asset/scene loading | FLECS_PLECS |
[Rules](/flecs/group__c__addons__rules.html) | Powerful prolog-like query language | FLECS_RULES |
[Snapshot](/flecs/group__c__addons__snapshot.html) | Take snapshots of the world & restore them | FLECS_SNAPSHOT |
[Stats](/flecs/group__c__addons__stats.html) | See what's happening in a world with statistics | FLECS_STATS |
[Monitor](/flecs/group__c__addons__monitor.html) | Periodically collect & store statistics | FLECS_MONITOR |
[Log](/flecs/group__c__addons__log.html) | Extended tracing and error logging | FLECS_LOG |
[Journal](/flecs/group__c__addons__journal.html) | Journaling of API functions | FLECS_JOURNAL |
[App](/flecs/group__c__addons__app.html) | Flecs application framework | FLECS_APP |
[OS API Impl](/flecs/group__c__addons__os__api__impl.html) | Default OS API implementation for Posix/Win32 | FLECS_OS_API_IMPL |
## Flecs Hub
[Flecs Hub](https://github.com/flecs-hub) is a collection of repositories that show how Flecs can be used to build game systems like input handling, hierarchical transforms and rendering.

Expand All @@ -249,8 +188,3 @@ The following language bindings have been developed with Flecs! Note that these
- [Zig #1](https://github.com/foxnne/zig-flecs) [#2](https://github.com/prime31/zig-flecs)
- [C# #1](https://github.com/flecs-hub/flecs-cs) [#2](https://git.mcft.net/copygirl/gaemstone.ECS)
- [Rust](https://github.com/jazzay/flecs-rs)
## Supporting Flecs ♥️
Supporting Flecs goes a long way towards keeping the project going and the community alive! If you like the project, consider:
- Giving it a star 🌟
- Becoming a sponsor: https://github.com/sponsors/SanderMertens
Loading

0 comments on commit 2e77e3e

Please sign in to comment.