go-sdl2
is SDL2 wrapped for Go users. It enables interoperability between Go and the SDL2 library which is written in C. That means the original SDL2 installation is required for this to work..go
files with go run
.apt install libsdl2{,-image,-mixer,-ttf,-gfx}-dev
yum install SDL2{,_image,_mixer,_ttf,_gfx}-devel
pacman -S sdl2{,_image,_mixer,_ttf,_gfx}
emerge -av libsdl2 sdl2-{image,mixer,ttf,gfx}
brew install sdl2{,_image,_mixer,_ttf,_gfx} pkg-config
i686-w64-mingw32
and/or x86_64-w64-mingw32
depending on the architecture you chose into your mingw-w64 folder e.g. C:Program Filesmingw-w64x86_64-6.3.0-win32-seh-rt_v5-rev1mingw64
C:Program Filesmingw-w64x86_64-6.3.0-win32-seh-rt_v5-rev1mingw64bin
and C:Program Filesmingw-w64x86_64-6.3.0-win32-seh-rt_v5-rev1mingw64x86_64-w64-mingw32bin
Git Bash
and run go get -v github.com/veandco/go-sdl2/sdl
.go install github.com/veandco/go-sdl2/{sdl,img,mix,ttf}
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-SDL2{,_image,_mixer,_ttf,_gfx}
go get -v github.com/veandco/go-sdl2/sdl
go get -v github.com/veandco/go-sdl2/img
go get -v github.com/veandco/go-sdl2/mix
go get -v github.com/veandco/go-sdl2/ttf
go get -v github.com/veandco/go-sdl2/gfx
go get -v github.com/veandco/go-sdl2/{sdl,img,mix,ttf}
go-sdl2
being under active development, a lot of breaking changes are going to happen during v0.x. With versioning system coming to Go soon, we'll make use of semantic versioning to ensure stability in the future..go-sdl2-libs
. To build statically, run:CGO_ENABLED=1 CC=gcc GOOS=linux GOARCH=amd64 go build -tags static -ldflags '-s -w'
CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 go build -tags static -ldflags '-s -w'
go get -v github.com/veandco/go-sdl2/sdl@master
pacman -S mingw-w64
.x86_64-w64-mingw32
folder inside recursively to the system's MinGW x86_64-w64-mingw32
folder. You may also do the same for the i686-w64-mingw32
folder.cp -r x86_64-w64-mingw32 /usr
.env CGO_ENABLED='1' CC='/usr/bin/x86_64-w64-mingw32-gcc' GOOS='windows' CGO_LDFLAGS='-lmingw32 -lSDL2' CGO_CFLAGS='-D_REENTRANT' go build -x main.go
. You can change some of the parameters if you'd like to. In this example, it should produce a main.exe
executable file.SDL2.dll
from the SDL2 runtime package (For others like SDL_image, SDL_mixer, etc., look for them here) for Windows in the same folder as your executable.brew install mingw-w64
x86_64-w64-mingw
folder inside recursively to the system's MinGW x86_64-w64-mingw32 folder
. You may also do the same for the i686-w64-mingw32
folder. The path to MinGW may be slightly different but the command should look something like cp -r x86_64-w64-mingw32 /usr/local/Cellar/mingw-w64/5.0.3/toolchain-x86_64
.env CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc GOOS=windows CGO_LDFLAGS='-L/usr/local/Cellar/mingw-w64/5.0.3/toolchain-x86_64/x86_64-w64-mingw32/lib -lSDL2' CGO_CFLAGS='-I/usr/local/Cellar/mingw-w64/5.0.3/toolchain-x86_64/x86_64-w64-mingw32/include -D_REENTRANT' go build -x main.go
. You can change some of the parameters if you'd like to. In this example, it should produce a main.exe
executable file.SDL2.dll
from the SDL2 runtime package (For others like SDL_image, SDL_mixer, etc., look for them here) for Windows in the same folder as your executable.SDL2.dll
and friends) in the same folder as your program.runtime.LockOSThread()
at the start of your main() usually solves the problem (see SDL2 FAQ about multi-threading).render_queue
or render_goroutines
examples from https://github.com/veandco/go-sdl2-examples to see how it works.brew remove sdl2_mixer
, then reinstall it with the MP3 option: brew install sdl2_mixer --with-flac --with-fluid-synth --with-libmikmod --with-libmodplug --with-smpeg2
. If necessary, check which options you can enable with brew info sdl2_mixer
. You could also try installing sdl2_mixer with mpg123 by running brew install sdl2_mixer --with-mpg123
.external
directory of SDL_mixer. Refer to issue #148 for instructions.sdl.Delay()
or put the rendering code inside a draw loop.