-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Working on Raspberry Pi
To build your raylib game for Raspberry Pi you just need to download raylib git repository (or get the current release from here). All required libraries come with the raylib, no additional dependencies are required. raylib also comes with ready-to-use makefiles to compile source code and examples.
WARNING: PLATFORM_RPI
is deprecated (only works with Raspbian Buster). Use PLATFORM_DRM
for latest RPI OS Bullseye.
raylib supports the following Raspberry Pi models:
- Raspberry Pi Zero (all models)
- Raspberry Pi 1 (all models)
- Raspberry Pi 2 (all models)
- Raspberry Pi 3 (all models)
- Raspberry Pi 4 (all models)
raylib supports the platforms/OSs, desktop and native modes:
-
PLATFORM_DESKTOP
: Raspberry Pi OS Bullseye desktop mode -
PLATFORM_DRM
: Raspberry Pi OS Bullseye native mode -
PLATFORM_RPI
: Rasberryy Pi OS (Legacy) (deprecated - based on Raspbian Buster) native mode
NOTE: RPI OS Bullseye is currently supported by all RPI models while RPI OS Legacy is only supported by RPI 0-3 models.
- OpenGL ES 2.0 in native mode (no X11 required) (
PLATFORM_DRM
orPLATFORM_RPI
) - OpenGL 1.1 on X11 desktop mode (
PLATFORM_DESKTOP
) - OpenGL 2.1 on X11 desktop mode (
PLATFORM_DESKTOP
)
By default, raylib should be compiled with PLATFORM_DESKTOP
on classic X11-based Linux desktop environment, using the provided OpenGL desktop drivers
. However, it is also possible to compile in native mode not depending on any windowing system (no X11 required).
When compiling for native mode, PLATFORM_DRM
or PLATFORM_RPI
should be used, depending on the RPI OS version, check previous point for details.
Before you can use raylib in your project you will have to compile it, but this is quick and easy!
Just navigate to raylib\src\
directory and run one of the following options depending on your needs:
1. To compile on desktop mode (X11 window)
make PLATFORM=PLATFORM_DESKTOP GRAPHICS=GRAPHICS_API_OPENGL_21
Raylib examples use GLSL 3.3 shaders. Older Raspberry Pi's 0-3 only support upto GLSL 1.2. If you are on Raspberry Pi OS desktop on something lower than RPi4 you will see that shaders will default to a base shader and examples may not look as intended. To fix this, we need to tell Raylib to load GLSL 1.2 versions of the shader in the .c file of the example which will look something like this:
#if defined(PLATFORM_DESKTOP)
#define GLSL_VERSION 120 // Change this back to 330 if compiling for a platform that supports GLSL3.3
#else // PLATFORM_RPI, PLATFORM_ANDROID, PLATFORM_WEB
#define GLSL_VERSION 100
#endif
Also, ensure the correct versions of the shaders are available in the raylib/examples/resources/shaders/glsl120 folder. Troubleshooting is easier while running your example from a terminal as raylib will log the errors over there.
NOTE on compilation errors: To use raylib on the Raspberry Pi desktop, you need to had previously installed all desktop window-dev system libraries, if you just downloaded Raspberry Pi OS Desktop, maybe it comes with required libraries installed but if it complains on compilation, just make sure to install the following libraries:
sudo apt-get install --no-install-recommends raspberrypi-ui-mods lxterminal gvfs
sudo apt-get install libx11-dev libxcursor-dev libxinerama-dev libxrandr-dev libxi-dev libasound2-dev mesa-common-dev libgl1-mesa-dev
2. To compile in native mode (no X11)
On Raspberry Pi models 0-3 using RPI OS Legacy:
make PLATFORM=PLATFORM_RPI
On Rapsberry Pi 0-4 using RPI OS Bullseye or newer:
make PLATFORM=PLATFORM_DRM
NOTE: To compile raylib in native mode on Raspberry Pi 4, you need the specific DRM libraries:
sudo apt-get install libdrm-dev libegl1-mesa-dev libgles2-mesa-dev libgbm-dev
raylib also works on DietPi distribution, following libraries are required:
sudo apt-get install libraspberrypi-dev raspberrypi-kernel-headers
sudo apt-get install build-essential
Just move to folder raylib/examples/
and run the same make command you used to compile raylib
www.raylib.com | itch.io | GitHub | Discord | YouTube
- Architecture
- Syntax analysis
- Data structures
- Enumerated types
- External dependencies
- GLFW dependency
- libc dependency
- Platforms and graphics
- Input system
- Default shader
- Custom shaders
- Coding conventions
- Integration with other libs
- Working on Windows
- Working on macOS
- Working on GNU Linux
- Working on Chrome OS
- Working on FreeBSD
- Working on Raspberry Pi
- Working for Android
- Working for Web (HTML5)
- Working on exaequOS Web Computer
- Creating Discord Activities
- Working anywhere with CMake
- CMake Build Options
- raylib templates: Get started easily
- How To: Quick C/C++ Setup in Visual Studio 2022, GCC or MinGW
- How To: C# Visual Studio Setup
- How To: VSCode
- How To: Eclipse
- How To: Sublime Text
- How To: Code::Blocks