Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gen2brain/raylib-go
Go bindings for raylib, a simple and easy-to-use library to enjoy videogames programming.
https://github.com/gen2brain/raylib-go
android game-engine golang raylib rpi video-game
Last synced: 2 days ago
JSON representation
Go bindings for raylib, a simple and easy-to-use library to enjoy videogames programming.
- Host: GitHub
- URL: https://github.com/gen2brain/raylib-go
- Owner: gen2brain
- License: zlib
- Created: 2017-01-27T08:31:45.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-10-28T08:11:01.000Z (about 2 months ago)
- Last Synced: 2024-10-29T15:07:25.746Z (about 1 month ago)
- Topics: android, game-engine, golang, raylib, rpi, video-game
- Language: C
- Homepage:
- Size: 34.5 MB
- Stars: 1,603
- Watchers: 18
- Forks: 164
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - raylib-go - Go bindings for [raylib](https://www.raylib.com/), a simple and easy-to-use library to learn videogames programming. (Game Development / Search and Analytic Databases)
- awesome-go - raylib-go - Go bindings for raylib, a simple and easy-to-use library to learn videogames programming. - ★ 293 (Game Development)
- awesome-go-extra - raylib-go - to-use library to enjoy videogames programming.|857|90|18|2017-01-27T08:31:45Z|2022-08-05T12:40:27Z| (Game Development / Advanced Console UIs)
- awesome-go - raylib-go - Go bindings for [raylib](https://www.raylib.com/), a simple and easy-to-use library to learn videogames programming. Stars:`1.6K`. (Game Development / Search and Analytic Databases)
README
![logo](https://goo.gl/XlIcXz)
## raylib-go
[![Build Status](https://github.com/gen2brain/raylib-go/actions/workflows/build.yml/badge.svg)](https://github.com/gen2brain/raylib-go/actions)
[![GoDoc](https://godoc.org/github.com/gen2brain/raylib-go/raylib?status.svg)](https://godoc.org/github.com/gen2brain/raylib-go/raylib)
[![Go Report Card](https://goreportcard.com/badge/github.com/gen2brain/raylib-go/raylib)](https://goreportcard.com/report/github.com/gen2brain/raylib-go/raylib)
[![Examples](https://img.shields.io/badge/learn%20by-examples-0077b3.svg?style=flat-square)](https://github.com/gen2brain/raylib-go/tree/master/examples)Golang bindings for [raylib](http://www.raylib.com/), a simple and easy-to-use library to enjoy videogames programming.
raylib C source code is included and compiled together with bindings. Note that the first build can take a few minutes.
It is also possible to use raylib-go without cgo (Windows only; see requirements below).
### Requirements
##### Ubuntu
apt-get install libgl1-mesa-dev libxi-dev libxcursor-dev libxrandr-dev libxinerama-dev libwayland-dev libxkbcommon-dev
##### Fedora
dnf install mesa-libGL-devel libXi-devel libXcursor-devel libXrandr-devel libXinerama-devel wayland-devel libxkbcommon-devel
##### macOS
On macOS, you need Xcode or Command Line Tools for Xcode (if you have `brew` installed, you already have this).
##### Windows
###### cgo
On Windows you need C compiler, like [Mingw-w64](https://mingw-w64.org) or [TDM-GCC](http://tdm-gcc.tdragon.net/).
You can also build binary in [MSYS2](https://msys2.github.io/) shell.To remove console window, build with `-ldflags "-H=windowsgui"`.
###### purego (without cgo, i.e. CGO_ENABLED=0)
Download the raylib.dll from the assets on the [releases page](https://github.com/raysan5/raylib/releases). It is contained in the `raylib-*_win64_msvc*.zip`.
Put the raylib.dll into the root folder of your project or copy it into `C:\Windows\System32` for a system-wide installation.It is also possible to build the DLL yourself. You can find more info at [raylib's wiki](https://github.com/raysan5/raylib/wiki/Working-on-Windows).
##### Android
[Android example](https://github.com/gen2brain/raylib-go/tree/master/examples/others/android/example).
### Installation
go get -v -u github.com/gen2brain/raylib-go/raylib
### Build tags
* `drm` - build for Linux native [DRM](https://en.wikipedia.org/wiki/Direct_Rendering_Manager) mode, including Raspberry Pi 4 and other devices (PLATFORM_DRM)
* `sdl` - build for [SDL](https://github.com/libsdl-org/SDL) backend (PLATFORM_DESKTOP_SDL)
* `sdl3` - build for [SDL3](https://github.com/libsdl-org/SDL) backend (PLATFORM_DESKTOP_SDL3)
* `rgfw` - build for [RGFW](https://github.com/ColleagueRiley/RGFW) backend (PLATFORM_DESKTOP_RGFW)
* `noaudio` - disables audio functions
* `opengl43` - uses OpenGL 4.3 backend
* `opengl21` - uses OpenGL 2.1 backend (default is 3.3 on desktop)
* `opengl11` - uses OpenGL 1.1 backend (pseudo OpenGL 1.1 style)
* `es2` - uses OpenGL ES 2.0 backend (can be used to link against [Google's ANGLE](https://github.com/google/angle))
* `es3` - experimental support for OpenGL ES 3.0
* `x11` - force X11 compatibility mode on Wayland (PLATFORM_DESKTOP/GLFW)
* `wayland` - force Wayland only mode (PLATFORM_DESKTOP/GLFW)### Documentation
Documentation on [GoDoc](https://godoc.org/github.com/gen2brain/raylib-go/raylib). Also check raylib [cheatsheet](http://www.raylib.com/cheatsheet/cheatsheet.html). If you have problems or need assistance there is an active community in the #raylib-go channel of the [Raylib Discord Server](https://discord.gg/raylib) that can help.
### Example
```go
package mainimport rl "github.com/gen2brain/raylib-go/raylib"
func main() {
rl.InitWindow(800, 450, "raylib [core] example - basic window")
defer rl.CloseWindow()rl.SetTargetFPS(60)
for !rl.WindowShouldClose() {
rl.BeginDrawing()rl.ClearBackground(rl.RayWhite)
rl.DrawText("Congrats! You created your first window!", 190, 200, 20, rl.LightGray)rl.EndDrawing()
}
}
```Check more [examples](https://github.com/gen2brain/raylib-go/tree/master/examples) organized by raylib modules.
### Cross-compile (Linux)
To cross-compile for Windows install [MinGW](https://www.mingw-w64.org/) toolchain.
```
$ CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -ldflags "-s -w"
$ file basic_window.exe
basic_window.exe: PE32+ executable (console) x86-64 (stripped to external PDB), for MS Windows, 11 sections$ CGO_ENABLED=1 CC=i686-w64-mingw32-gcc GOOS=windows GOARCH=386 go build -ldflags "-s -w"
$ file basic_window.exe
basic_window.exe: PE32 executable (console) Intel 80386 (stripped to external PDB), for MS Windows, 9 sections
```To cross-compile for macOS install [OSXCross](https://github.com/tpoechtrager/osxcross) toolchain.
```
$ CGO_ENABLED=1 CC=x86_64-apple-darwin21.1-clang GOOS=darwin GOARCH=amd64 go build -ldflags "-linkmode external -s -w '-extldflags=-mmacosx-version-min=10.15'"
$ file basic_window
basic_window: Mach-O 64-bit x86_64 executable, flags:$ CGO_ENABLED=1 CC=aarch64-apple-darwin21.1-clang GOOS=darwin GOARCH=arm64 go build -ldflags "-linkmode external -s -w '-extldflags=-mmacosx-version-min=12.0.0'"
$ file basic_window
basic_window: Mach-O 64-bit arm64 executable, flags:
```### License
raylib-go is licensed under an unmodified zlib/libpng license. View [LICENSE](https://github.com/gen2brain/raylib-go/blob/master/LICENSE).