Skip to content

A small usage example on how to build and use SDL.zig

Notifications You must be signed in to change notification settings

ikskuh/SDL.zig-Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SDL2 with Zig

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.

Screenshot

Building

This example requires Zig master, you can obtain a copy for your system here.

Prerequisites

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.

Linux

Install the development packages listed below and invoke zig build.

Packages (Debian, Ubuntu)

  • libsdl2-dev
  • libsdl2-image-dev

Packages (Arch Linux, Manjaro)

  • sdl2
  • sdl2_image

Windows

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.

MacOS

Install sdl2 and sdl2_image via brew:

brew install sdl2
brew install sdl2_image

then invoke zig build.

Cross-Build (Host: Linux, Target: Windows)

Just follow the instructions for building for Windows, but use MinGW 32/64-bit. Using Visual C++ 32/64-bit will not work!

Cross-Build (Host: Windows, Target: Linux)

Not supported atm. Use WSL for this.

About

A small usage example on how to build and use SDL.zig

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages