About this project
raylib-go provides Golang bindings for raylib, a simple and easy-to-use library designed for videogame programming. The raylib C source code is included and compiled together with the bindings as part of the build process.
Installation is done via the standard Go toolchain:
go get -v -u github.com/gen2brain/raylib-go/raylib
The library supports two build modes. The default mode uses cgo and requires platform-specific system libraries. On Ubuntu, this includes libgl1-mesa-dev, libxi-dev, libxcursor-dev, libxrandr-dev, libxinerama-dev, libwayland-dev, and libxkbcommon-dev. On Fedora, the equivalent packages are mesa-libGL-devel, libXi-devel, libXcursor-devel, libXrandr-devel, libXinerama-devel, wayland-devel, and libxkbcommon-devel. On macOS, Xcode or the Command Line Tools are needed. On Windows, a C compiler such as MinGW-w64 or TDM-GCC is required. For Android, an example is available in the repository. Web/Wasm support is available through a separate compatible project called Raylib-Go-Wasm.
Alternatively, raylib-go can be used without cgo by setting CGO_ENABLED=0. This purego mode is supported on Linux, macOS, Windows, and FreeBSD (32-bit is not supported). Pre-built shared libraries are embedded for Linux arm64/amd64, macOS arm64/amd64, and Windows arm64/amd64. The build tag raylib_no_embed or the environment variable RAYLIB_NO_EMBED=1 can disable this embedding feature.
A variety of build tags allow customizing the target platform and backend:
- drm: builds for Linux native DRM mode, including Raspberry Pi 4
- sdl: uses the SDL backend
- sdl3: uses the SDL3 backend
- rgfw: uses the RGFW backend
- noaudio: disables audio functions
- opengl43, opengl21, opengl11: select specific OpenGL backend versions
- es2, es3: OpenGL ES 2.0 and experimental 3.0 backends
- x11: forces X11 compatibility mode on Wayland
- wayland: forces Wayland-only mode
Cross-compilation is supported from Linux using cgo. Windows targets require the MinGW toolchain, while macOS targets require the OSXCross toolchain. Sample build commands are provided in the repository for producing both 64-bit and 32-bit Windows executables, as well as x86_64 and arm64 macOS binaries.
An example program demonstrates the basic usage pattern: initializing a window, running a game loop, drawing text, and closing the window. More examples are organized by raylib modules in the repository's examples directory.
Documentation is available on GoDoc, and a raylib cheatsheet is also referenced. Community support is available on the Raylib Discord Server in the #raylib-go channel.
raylib-go is licensed under an unmodified zlib/libpng license.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.