sdl3-sample/README.md

1.2 KiB

SDL3 Sample Project with Zig Bindings

A sample SDL3 application using Zig-native bindings instead of C imports.

Features

  • SDL3 window initialization and management
  • Zig-native API bindings vendored from sdl3bind
  • Event loop with keyboard input handling
  • Exits on pressing Escape key
  • Basic rendering with color clear

Structure

  • src/main.zig - Main application using Zig SDL3 bindings
  • sdl3-zig/ - Vendored Zig bindings for SDL3
    • sdl3.zig - Main module that re-exports all SDL3 APIs
    • sdl3/ - Individual API modules (init, video, events, render, etc.)
    • sdl3/c.zig - C import wrapper for SDL3 headers
  • build.zig - Build configuration
  • build.zig.zon - Package manifest

Dependencies

  • SDL3 (castholm's Zig port) - v0.4.0+3.4.0
  • SDL3 Zig bindings - official/release-3.4.0

Building

zig build

Running

zig build run

Press Escape to exit the application.

Notes

  • Uses Zig 0.15.2 API
  • The Zig bindings provide type-safe, Zig-friendly wrappers around SDL3's C API
  • Opaque pointer types require @ptrCast when crossing between binding and C types
  • All SDL3 functions are accessed through the sdl import (e.g., sdl.init_fn(), sdl.video.createWindow())