• Stars
    star
    1,246
  • Rank 36,174 (Top 0.8 %)
  • Language
    C
  • License
    zlib License
  • Created over 7 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Go bindings for raylib, a simple and easy-to-use library to enjoy videogames programming.

logo

raylib-go

Build Status GoDoc Go Report Card Examples

Golang bindings for raylib, 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.

Windows
cgo

On Windows you need C compiler, like Mingw-w64 or TDM-GCC. You can also build binary in MSYS2 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. 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.

As of November 15, 2023, raylib 5.0 is the required version.

It is also possible build the dll yourself. You can find more infos at raylib's wiki.

Android

Android example.

Installation

go get -v -u github.com/gen2brain/raylib-go/raylib

Build tags

  • drm - build for Linux native DRM mode, including Raspberry Pi 4 and other devices (PLATFORM_DRM)
  • sdl - build for SDL backend instead of internal GLFW (PLATFORM_DESKTOP_SDL)
  • 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)
  • es3 - experimental support for OpenGL ES 3.0
  • x11 - force X11 compatibility mode on Wayland

Documentation

Documentation on GoDoc. Also check raylib cheatsheet. If you have problems or need assistance there is an active community in the #raylib-go channel of the Raylib Discord Server that can help.

Example

package main

import 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 organized by raylib modules.

Cross-compile (Linux)

To cross-compile for Windows install MinGW 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 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:<NOUNDEFS|DYLDLINK|TWOLEVEL>

$ 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:<NOUNDEFS|DYLDLINK|TWOLEVEL|PIE>

License

raylib-go is licensed under an unmodified zlib/libpng license. View LICENSE.

More Repositories

1

beeep

Go cross-platform library for sending desktop notifications, alerts and beeps
Go
1,321
star
2

cam2ip

Turn any webcam into an IP camera
Go
812
star
3

url2img

HTTP server with API for capturing screenshots of websites
Go
530
star
4

dlgs

Go cross-platform library for displaying dialogs and input boxes
Go
377
star
5

go-fitz

Golang wrapper for the MuPDF Fitz library
C
339
star
6

go-unarr

Go bindings for unarr (decompression library for RAR, TAR, ZIP and 7z archives)
Go
267
star
7

malgo

Mini audio library
C
256
star
8

iup-go

Cross-platform UI library with native controls
Go
250
star
9

goiv

Small and simple image viewer written in pure Go.
Go
201
star
10

x264-go

Go bindings for x264
Go
194
star
11

cbconvert

CBconvert is a Comic Book converter
Go
155
star
12

shm

System V shared memory functions in pure Go.
Go
122
star
13

mpeg

MPEG-1 Video decoder, MP2 Audio decoder and MPEG-PS Demuxer in pure Go
Go
113
star
14

bukanir

Bukanir streams movies and TV shows from bittorrent magnet links
Java
85
star
15

aac-go

Go bindings for vo-aacenc
Go
54
star
16

gsmgo

GSMGo is SMS HTTP server with REST API
Go
50
star
17

keepalived_exporter

Keepalived Prometheus Exporter
Go
41
star
18

go-sdl2-android-example

Go-SDL2 example running on Android
Java
32
star
19

vov

VoV is a high score game for Android
Go
30
star
20

volti

Volti is GTK+ application for controlling audio volume from system tray/notification area
Python
28
star
21

pyhtmleditor

PyQt WYSIWYG HTML Editor
Python
26
star
22

acra-go

Backend for Application Crash Reports for Android (ACRA)
Go
24
star
23

go-mpv

Go bindings for libmpv
Go
21
star
24

flite-go

Go bindings for Flite (festival-lite)
Go
14
star
25

jpegxl

JPEG XL image encoder/decoder
Go
11
star
26

crtaci

"Crtaći" searches YouTube, DailyMotion and Vimeo for good old cartoons
Go
10
star
27

vidextr

Simple video extractor for YouTube, DailyMotion and Vimeo in Go.
Go
10
star
28

comic-utils

Comic book archive utils
Python
6
star
29

oss

oss provides access to OSS (Open Sound System) audio interface
Go
6
star
30

svg

SVG icon decoder
Go
6
star
31

avif

AVIF image encoder/decoder
Go
5
star
32

jxl

Go decoder for JPEG XL image format
C
4
star
33

framebuffer

Fork of removed repo github.com/jteeuwen/framebuffer
Go
4
star
34

mpeg-examples

Examples for mpeg library
Go
4
star
35

go-smpeg2

Golang bindings for the smpeg2 - SDL2 MPEG Player Library
Go
4
star
36

jpegli

Go encoder/decoder for JPEG based on jpegli
Go
3
star
37

prang

A violent point-and-shoot game for android
C
2
star
38

bgradio

Qt/libVLC online radio streaming player that runs in system tray
Python
2
star
39

heic

HEIC image decoder
Go
2
star
40

webp

WebP image encoder/decoder
Go
2
star
41

vim

My Vim config
Vim Script
1
star
42

base64

Fork of goost.org/encoding/base64
Go
1
star
43

umtsmon

Qt4 port of umtsmon
C++
1
star
44

libtorrent-go

SWIG Go bindings for libtorrent-rasterbar
C++
1
star