This is a simple example project that renders the classic bouncing DVD logo with SDL2. This example is a minimal example on how to set up a fully deployable project with Zig.
This example requires Zig master, you can obtain a copy for your system here.
Clone this repository with git
recursively and change into the cloned working directory:
git clone https://github.com/MasterQ32/SDL.zig-Example sdl-example --recursive
cd sdl-example
If you don't want to use submodules, obtain a copy of SDL.zig and copy it into deps/sdl
.
Install the development packages listed below and invoke zig build
.
libsdl2-dev
libsdl2-image-dev
sdl2
sdl2_image
Windows has no pre-built SDL2 neither a package manager. This means you have to download the development libraries from libsdl.org for either Visual C++ 32/64-bit or MinGW 32/64-bit and extract it into a folder.
The same must be done for the SDL_image
development libraries. Chose the same abi/compiler as your SDL2 download above.
Then, use
zig build -Dsdl-sdk=C:\Users\MYUSERNAME\...\SDL2-2.X.Y -Dsdl-image-sdk=C:\Users\MYUSERNAME\...\SDL2_image-2.Z.W
to build your project. The build script will auto-detect depending on your target if the Visual C++ 32/64-bit or MinGW 32/64-bit folder layout should be used.
Install sdl2
and sdl2_image
via brew:
brew install sdl2
brew install sdl2_image
then invoke zig build
.
Just follow the instructions for building for Windows, but use MinGW 32/64-bit. Using Visual C++ 32/64-bit will not work!
Not supported atm. Use WSL for this.