ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - gen2brain/raylib-go: Go bindings for raylib, a simple and easy-to-use library to enjoy videogames programming.
Go bindings for raylib, a simple and easy-to-use library to enjoy videogames programming. - gen2brain/raylib-go
Visit Site

GitHub - gen2brain/raylib-go: Go bindings for raylib, a simple and easy-to-use library to enjoy videogames programming.

GitHub - gen2brain/raylib-go: 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 to build the DLL yourself. You can find more info 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 (PLATFORM_DESKTOP_SDL)
  • rgfw - build for 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)
  • es3 - experimental support for OpenGL ES 3.0
  • x11 - force X11 compatibility mode on Wayland (PLATFORM_DESKTOP/GLFW)

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.

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory