go-sdl2 is a straightforward Go wrapper for SDL2.
Where makes sense, it'll use methods instead of functions (such as window.UpdateSurface() or surface.Free() instead of sdl.UpdateWindowSurface(window) or sdl.FreeSurface(surface)).
On Fedora 20, you can run this command to install all the development
files:
yum install SDL2{,_mixer,_image,_ttf}-devel
On Arch Linux, type:
pacman -S sdl2{,_mixer,_image,_ttf}
To get the bindings, type:
go get -v github.com/jackyb/go-sdl2/sdl
go get -v github.com/jackyb/go-sdl2/sdl_mixer
go get -v github.com/jackyb/go-sdl2/sdl_image
go get -v github.com/jackyb/go-sdl2/sdl_ttf
or type this if you use Bash terminal:
go get -v github.com/jackyb/go-sdl2/sdl{,_mixer,_image,_ttf}
package main
import "github.com/jackyb/go-sdl2/sdl"
func main() {
window := sdl.CreateWindow("test", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
800, 600, sdl.WINDOW_SHOWN)
surface := window.GetSurface()
rect := sdl.Rect { 0, 0, 200, 200 }
surface.FillRect(&rect, 0xffff0000)
window.UpdateSurface()
sdl.Delay(1000)
window.Destroy()
}
For more complete examples, see inside the examples folder.
For now, take a look at http://godoc.org/github.com/jackyb/go-sdl2/sdl.
Go-SDL2 is BSD 3-clause licensed.