All Projects → CapsCollective → raylib-cpp-starter

CapsCollective / raylib-cpp-starter

Licence: Zlib License
A portable, automated template for raylib projects with C++ bindings

Programming Languages

Makefile
30231 projects
C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to raylib-cpp-starter

Luxe Alpha
luxe alpha - deprecated, unrelated to the new engine! see the readme or website for details - https://luxeengine.com/
Stars: ✭ 559 (+1646.88%)
Mutual labels:  game-engine, game-dev
Donerserializer
A C++14 JSON Serialization Library
Stars: ✭ 31 (-3.12%)
Mutual labels:  game-engine, game-dev
Glas
WebGL in WebAssembly with AssemblyScript
Stars: ✭ 278 (+768.75%)
Mutual labels:  game-engine, game-dev
Raylib
A simple and easy-to-use library to enjoy videogames programming
Stars: ✭ 8,169 (+25428.13%)
Mutual labels:  game-engine, raylib
O2
2D Game Engine with visual WYSIWYG editor
Stars: ✭ 121 (+278.13%)
Mutual labels:  game-engine, game-dev
Is Engine
SFML C++ game engine that allows to create games on Web (HTML 5 - CSS 3), Android and PC
Stars: ✭ 94 (+193.75%)
Mutual labels:  game-engine, game-dev
Entt
Gaming meets modern C++ - a fast and reliable entity component system (ECS) and much more
Stars: ✭ 6,017 (+18703.13%)
Mutual labels:  game-engine, game-dev
Uecs
Ubpa Entity-Component-System (U ECS) in Unity3D-style
Stars: ✭ 174 (+443.75%)
Mutual labels:  game-engine, game-dev
Gamedev Resources
🎮 🎲 A wonderful list of Game Development resources.
Stars: ✭ 2,054 (+6318.75%)
Mutual labels:  game-engine, game-dev
Lumberyard
Amazon Lumberyard is a free AAA game engine deeply integrated with AWS and Twitch – with full source.
Stars: ✭ 1,785 (+5478.13%)
Mutual labels:  game-engine, game-dev
Goluwa
a game framework written in luajit
Stars: ✭ 173 (+440.63%)
Mutual labels:  game-engine, game-dev
learn-dlang
Learn D programming language by creating games!
Stars: ✭ 42 (+31.25%)
Mutual labels:  raylib, game-dev
vue3-boilerplate
A Vue 3 Starter Boilerplate with Vue Router 4, Vuex 4, TypeScript 4, Webpack 5, Prettier and More.
Stars: ✭ 133 (+315.63%)
Mutual labels:  starter-template
OpenCoreMMO
Open-source MMORPG server emulator written in C#
Stars: ✭ 157 (+390.63%)
Mutual labels:  game-dev
meta2d
Meta2D is open source WebGL 2D game engine for making cross platform games.
Stars: ✭ 33 (+3.13%)
Mutual labels:  game-engine
Pygin
Simple game engine produced for making easier to build more complex games using Python.
Stars: ✭ 21 (-34.37%)
Mutual labels:  game-engine
CLUSEK-RT
Vulkan based C++ ray-tracing game engine.
Stars: ✭ 24 (-25%)
Mutual labels:  game-engine
YokosukaJS
A functional programming-style beat-em-up game engine written in javascript
Stars: ✭ 18 (-43.75%)
Mutual labels:  game-engine
DartGodot
Godot + Dart 🎯
Stars: ✭ 79 (+146.88%)
Mutual labels:  game-engine
zetaframe
lightweight zig game framework.
Stars: ✭ 14 (-56.25%)
Mutual labels:  game-engine

Raylib C++ Starter

The Raylib C++ Starter kit is a template project that provides a simple starter template for the raylib game tools library incorporating the raylib-cpp C++ bindings and using Make for building. The starter kit can automatcially clone down raylib and the bindings, compile them, and setup the project for separate compilation using a static library.

Why static linking?

One of the most absurdly annoying things about C++ development is finding and linking dynamic libraries. The raylib project prides itself on having "NO external dependencies", and we tend to agree that portability is way cooler than saving that fraction of a second on compile-time.

Why not just use CMake?

I guess we just don't want the added headache. CMake is complex and sometimes feels like some arcane magic that we generally take for granted in build systems. If you look at the raylib library, yes it has CMake support, but it generally encourages the use of Make on all platforms because as the library reads:

raylib is a programming library to enjoy videogames programming; no fancy interface, no visual helpers, no auto-debugging... just coding in the most pure spartan-programmers way

So that being said, we hope that this repository finds you well and wholeheartedly enjoying the simple things in life (i.e. video games programming).

Current Compatibility

OS Default Compiler Last Manual Build Compile Status
macOS Clang++ Big Sur 11.0.1 macOS Status
Linux G++ Ubuntu 20.04 LTS Linux Status
Windows MinGW (G++) Windows 10 19041 Windows Status

Getting Started

Installing Dependencies

Before building the project, you will need to install all relevant dependencies for your platform so that the project has access to all the tools required, and raylib can compile and link correctly. You can find intructions for installing dependencies on macOS, Linux, and Windows in the docs file on installing dependencies.

Building the Project

Once you have cloned this repository and installed dependencies, building the project is as simple as running these two commands in its root directory:

macOS & Linux

$ make setup
$ make

Windows

> mingw32-make setup
> mingw32-make

The first command will clone in the lastest C++ bindings and targeted version of raylib, copy across any relevant header files into /includes, and build a static library file from them, placing it in /lib. The second command then compiles, runs and cleans up your project using the source code in /src/main.cpp.

If a window pops up, congratulations, you've successfully built the project and you can now start programming your game!

Using This Template

Now that you have the project setup and compiling on your system, it's time to start programming! If you aren't already familliar with raylib, we recommend looking over this awesome cheatsheet which lists every function, struct and macro available in the raylib C library. If you want specifics on how to use the C++ bindings, then you should check out the raylib-cpp repo, which nicely explains how the bindings work and contains raylib's examples ported to C++.

Once you're up and running, we first of all recommend that all your code for the game should go into the /src directory, which is automatically included in the compile process when you run Make. The default entry point for the program is /src/main.cpp (which is pretty standard). If you wish to change the program entry point, add more libraries, or really anything about your project, all build instructions are specified in the Makefile - no smoke and mirrors!

Making Use of Separate Compilation

When building compiled applications from scratch, each source file needs to be compiled into an object file in order for them all to be linked together as a full program. This can become rather time-consuming and inefficient as your codebase expands to use tens or even hundreds of files that recompile each time you build. Fortunately, with a few clever rules in our Makefile, we can be sure to only have to recompile files affected by our changes.

By using the following Make commands instead of the default target, we can skip the cleanup step, and only recompile files that changed:

macOS & Linux

$ make bin/app; make execute

Windows

> mingw32-make bin/app && mingw32-make execute

Using this method can save you a huge amount of time compiling (in reality, just a few seconds) each time you make a small change to your code! If you want to know more about how it works, you should have a read through the docs entry explaining the Makefile.

While separate compilation works quite well in most scenarios, it's not magic, and there are a few caveats to take note of here:

  1. Changing .h files will often result in longer compile times by causing all files that include them to recompile
  2. Constant changes to files included by many others in your program (like a base-class) will also cause all of those dependent to recompile
  3. Including widely-scoped files (like the whole of raylib-cpp.hpp) will add all of its own includes as dependent and increase the build time
  4. Placing includes in .h files instead of forward-declarations will also increase recursive includes and therefore the build time

Passing Args to the Executable

For working with some projects, you may want to pass arguments to the program once it's been built. This can be achieved by assigning values to the ARGS flag in the Makefile like below:

macOS & Linux

$ make ARGS="--somearg"

Windows

> mingw32-make ARGS="--somearg"

Specifying Custom Macro Definitions

You may also want to pass in your own macro definitions for certain configurations (such as setting log levels). You can pass in your definitions using CXXFLAGS:

macOS & Linux

$ make CXXFLAGS=-DMY_MACRO=1

Windows

> mingw32-make CXXFLAGS=-DMY_MACRO=1

Specifying a Non-Default Compiler

If you want to use a compiler for your platform that isn't the default for your system (or potentially you would like to explicitly state it), you can make use of the system-implicit CXX variable like so:

macOS & Linux

$ make CXX=g++

Windows

> mingw32-make CXX=g++

Contributing

How do I contribute?

It's pretty simple actually:

  1. Fork it from here
  2. Create your feature branch (git checkout -b cool-new-feature)
  3. Commit your changes (git commit -m "Added some feature")
  4. Push to the branch (git push origin cool-new-feature)
  5. Create a new pull request for it!

Contributors

Licence

This project is licenced under an unmodified zlib/libpng licence, which is an OSI-certified, BSD-like licence that allows static linking with closed source software. Check LICENCE for further details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].