Skip to content

lishacodesgames/Raylib-Template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Raylib Template

Minimal game template using raylib as a git submodule and CMake.
This repository is intended to be used as a starting point for a new raylib project.

I also have a more modular (lib-based) template, check it out

How to Clone

git clone --recursive to get the raylib submodule local

If you forgot, do:
git submodule update --init --recursive after regular git clone

Project Structure

What your project architecture should ideally look like for the CMakeLists.txt I've included (Can change accordingly, otherwise)

‖
‖——.git*
‖——CMakeLists.txt
‖——CMakePresets.json
‖——include/
‖  ‖——*.h or *.hpp → all *your* header files
‖——src/
‖  ‖——main.cpp
‖  ‖——*.cpp  → all other source files
‖——raylib/   → your raylib engine (submodule)

Build

mkdir build cd build
cmake --preset Debug OR cmake --preset Release -- (configuration of cmake)
cmake --build --preset Debug OR cmake --build --preset Release -- (compilation + build of your files, only what has changed since last build)

Check out CMakePresets.json if you're confused

Executable will appear in build/ under preset name

Linux Dependencies

Raylib requires a lot of libraries that are built-in on Mac and Windows.
No worries, Linux just requires 1 command to install them all:

sudo apt install \
    libx11-dev \
    libxcursor-dev \
    libxrandr-dev \
    libxi-dev \
    libxinerama-dev \
    libgl1-mesa-dev \
    libasound2-dev \
    libpulse-dev \
    libxkbcommon-dev

Add New Source Files

Put any new .cpp or .c files in src/
Update CMakeLists.txt as needed, example:

add_executable(YourProjectName
  src/main.cpp
  src/other_file.cpp
)

Updating raylib (the submodule)

cd raylib
git pull
cd ..
git add raylib
git commit -m "Updated raylib submodule"

Requirements

  • CMake 3.20+
  • C++ compiler: GCC / Clang
  • Ninja (not required, but it's what the presets use)

About

A base setup raylib game with a slimmed raylib submodule (my own). Basically a boilerplate for raylib games

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors