Skip to content

hybridgroup/go-sdl2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SDL2 binding for Go

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)).

Requirements

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}

Installation

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}

Example

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.

Documentation

For now, take a look at http://godoc.org/github.com/jackyb/go-sdl2/sdl.

Contributors

License

Go-SDL2 is BSD 3-clause licensed.

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%