C++ Game Dev Libraries: Raylib & Flecs
Tags: cpp, gamedev
Published: 2024-03-06 17:58:27

---
title: "C++ Game Dev Libraries: Raylib & Flecs"
published: "true"
description: "C++ game dev libraries 🎮 a look at the lightweight Raylib C/C++ game development framework and Flecs entity component system."
tags: "cplusplus, gamedev"
canonical_url: "https://rodneylab.com/c++-game-dev-libraries/"
cover_image: "https://dev-to-uploads.s3.amazonaws.com/uploads/articles/atzwhiuaqf7htc5h6d0v.png"
---

## 🖥️ C++ Game Development Libraries

In this post, we look at a couple of C++ game dev libraries.  Godot and Unreal Engine, among others, allow you to create fully-featured games with fantastic lighting using in-built editors.  When it comes to **learning game development**, as well as **quick prototyping**, a lightweight alternative is often preferable.

**Raylib** is a lightweight C/C++ game development framework, ideal for prototyping.  We see some resources for getting up-to-speed with Raylib, using C++ in this post.

We will also take a peek at **Flecs**, a C/C++ entity component system, providing access to a modern, composition over inheritance approach.

Raylib and Flecs pair well, and both support compilation to WebAssembly (**WASM**), which is brilliant for prototyping, letting you share your work on the web.  That is with no need for your audience to install apps in order to see your work.

Let me know if you find the post useful, and of course, if you would like to see similar content covering other C++ tooling.
</div>

![C++ Game Dev Libraries — Arkanoid clone — screen capture shows red ball, which bounces off the window walls and occasionally collides with rows of yellow bricks arranged at the top of the screen, destroying them on contact.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vnjk2ssy7cihpceesqmm.png)

## ☀️ Raylib Getting Started Resources

**Simple, easy-to-use game development library.**

Raylib 5&rsquo;s release, last year, marked the tenth anniversary of the Raylib 1.0 release.  Over that period, the library has been battle-tested and built up a community, which is great for finding content on getting started.


Raylib uses **OpenGL**, has full 3D support, you can develop with it on Linux, macOS and Windows, and you can also compile your game to WASM using <a href="https://emscripten.org/">Emscripten</a>, making it quite accessible.  Set up your Raylib project with CMake to make it accessible to developers working on different platforms.

The quickest way to get going with Raylib in C++ is to clone a CMake template repo, and <a href="https://www.raylib.com/cheatsheet/cheatsheet.html">get a copy of the Raylib Cheat Sheet</a> (also available as a PDF).  The Raylib Cheat Sheet is a list of all the functions that the API exposes, great for poking around and modifying demo code for learning purposes.

There are **Rust** and **Zig** Raylib bindings, though <a href="https://rodneylab.com/rust-for-gaming/#rust-for-gaming-macroquad">if you prefer working in Rust, you might consider Macroquad</a>, which was inspired by Raylib.

**Learn more about Raylib here**:
- GitHub repo: <a href="https://github.com/raysan5/raylib">raysan5/raylib</a>
- Official Site: <a href="https://www.raylib.com/">Raylib</a>
- Code examples: <a href="https://www.raylib.com/examples.html">Raylib Code Examples</a>
- CMake C++ template: <a href="https://github.com/SasLuca/raylib-cmake-template">CMake template for Raylib</a>
- Discord: <a href="https://discord.gg/raylib">Join the Raylib Discord Server</a>

## 💪🏽 Flecs Getting Started Resources

**Fast and lightweight ECS.**

<a href="https://github.com/SanderMertens/ecs-faq">Entity Component Systems offer an alternative game data storage pattern</a>, to a fully object-oriented approach.  The ECS approach can be more maintainable as well as performant.  Though not needed for all games, when you do want an ECS, you will want something performant, with a small footprint, which is where Flecs comes in.

Flecs compiles to WASM, using Emscripten, letting you deploy game demos as web pages.  It has fantastic documentation, and you can see dozens of examples in C as well as C++ in the Flecs GitHub repo.

An alternative, <a href="https://github.com/skypjack/entt">popular C++ ECS is EnTT</a>, which is used in Minecraft, among other games.

**Learn more about Flecs here**:
- GitHub repo: <a href="https://github.com/SanderMertens/flecs">SanderMertens/flecs</a>
- Official Quick-start: <a href="https://www.flecs.dev/flecs/md_docs_2Quickstart.html">Flecs Quick-start</a>
- Code Examples: <a href="https://github.com/SanderMertens/flecs/tree/master/examples">Flecs Examples</a>
- Discord: <a href="https://discord.gg/BEzP5Rgrrp">Join the Flecs Discord Server</a>

## Other C++ Game Dev Tooling

Of course, there is other C++ game-dev related tooling, alternative game frameworks to Raylib that you might consider are:

- <a href="https://www.libcinder.org/">Cinder</a>;
- <a aria-label="S D L" href="https://www.libsdl.org/">SDL</a>; and
- <a aria-label="S F M L" href="https://www.sfml-dev.org/">SFML</a>.

For creating a game backend, or just <a href="https://github.com/ocornut/imgui">displaying diagnostics, on-screen during development, Dear ImGui</a> is also popular.

## 🙌🏽 C++ Game Dev Libraries: Wrapping Up

In this C++ game dev libraries, we had a look at some C++ game dev tooling and the features offered.  More specifically, we saw:

- why you might consider **Raylib for prototyping a game**;
- links to content for **getting started with the Flecs ECS**; and
- some **alternative C++ game frameworks and ECSs**.

I hope you found this useful.  Do let me know if you would like to see more similar content.  Also reach out if there is anything I could improve to provide a better experience for you.

## 🙏🏽 C++ Game Dev Libraries: Feedback

If you have found this post useful, see links below for further related content on this site.  Let me know if there are any ways I can improve on it. I hope you will use the code or starter in your own projects. Be sure to share your work on X, giving me a mention, so I can see what you did. Finally, be sure to let me know ideas for other short videos you would like to see. Read on to find ways to get in touch, further below. If you have found this post useful, even though you can only afford even a tiny contribution, please <a aria-label="Support Rodney Lab via Buy me a Coffee" href="https://rodneylab.com/giving/">consider supporting me through Buy me a Coffee</a>.

Finally, feel free to share the post on your social media accounts for all your followers who will find it useful. As well as leaving a comment below, you can get in touch via <a href="https://twitter.com/messages/compose?recipient_id=1323579817258831875">@askRodney</a> on X (previously Twitter) and also, join the <a href="https://matrix.to/#/%23rodney:matrix.org">#rodney</a> Element Matrix room. Also, see <a aria-label="Get in touch with Rodney Lab" href="https://rodneylab.com/contact/">further ways to get in touch with Rodney Lab</a>. I post regularly on <a href="https://rodneylab.com/tags/gaming/">Game Dev</a> as well as <a href="https://rodneylab.com/tags/rust/">Rust</a> and <a href="https://rodneylab.com/tags/c++/">C++</a> (among other topics). Also, <a aria-label="Subscribe to the   Rodney Lab newsletter" href="https://newsletter.rodneylab.com/issue/latest-issue">subscribe to the newsletter to keep up-to-date</a> with our latest projects.