Skip to content
Nickolay edited this page Aug 15, 2016 · 8 revisions

Step 1: Installing SDL2

Before we can start using go-sdl2, we need to install the native version of SDL2.

Linux

On Linux, most of the popular distributions have SDL2 in their package repository. The following describes a command that can install SDL2 on specific Linux distributions. Note: some older distributions may be missing some if not all of the SDL2 packages. In that case, we may install SDL2 by compiling the source which will be described below.

Fedora

dnf install SDL2{,_image,_mixer,_ttf,_gfx}-devel

Arch Linux

pacman -S sdl2{,_image,_mixer,_ttf,_gfx}

Debian / Ubuntu

apt-get install libsdl2{,-image,-mixer,-ttf,-gfx}-dev

macOS

TODO

Windows

TODO

Step 2: Installing go-sdl2

After we installed SDL2, we can proceed to installing go-sdl2.

You can install go-sdl2 by running the following command: go get -v github.com/veandco/go-sdl2/sdl

Step 3: Running one of the examples

Now to see if everything was installed correctly, let's try running one of the examples. Go to go-sdl2's examples/gfx directory and run: go run gfx.go

If it manages to launch a window without a compile&runtime errors, that means you have installed go-sdl2 successfully and ready to create your own go-sdl2 programs!

TODO (suggestion): Lesson 2: Creating & handling window. Lesson 3: Basic shapes (circle, rect, etc)