Giter Club home page Giter Club logo

zig-gamedev's Introduction

Project requires Zig 0.10.0-dev.2412 (master) or newer to compile.

zig-gamedev project

This repository contains a collection of sample applications and cross-platform, composable libraries written in Zig programming language. Currently, it provides a solution for: cross-platform graphics, multi-threaded physics, SIMD math, procedural content generation (basic), profiling and more.

The goal of the project is to build a toolbox of libraries for Zig game developers. A lot of effort is being put to make the whole package consistent and let the developer use only the components she needs. Project is being developed by contributors and by one full-time developer.

If you are interested, please see Monthly Progress Reports and our Roadmap.

To get started on Windows/Linux/Mac try out physically based rendering (wgpu) sample:

(git with Git LFS extension and Zig 0.10.0-dev.2412 (master) or newer is required)

git clone https://github.com/michal-z/zig-gamedev.git
cd zig-gamedev
zig build physically_based_rendering_wgpu-run

Cross-platfrom (Win/Lin/Mac) libraries:

Windows libraries:

  • zwin32 - Zig bindings for Win32 API
  • zd3d12 - helper library for working with DirectX 12
  • zxaudio2 - helper library for working with XAudio2
  • zpix - support for GPU profiling with PIX
  • Interop with Direct2D and DirectWrite for high-quality vector graphics and text rendering (optional)

Project vision:

  • Works on Windows, Linux and MacOS
  • Has zero dependency except Zig compiler (master), git with Git LFS and curl - no Visual Studio, Build Tools, Windows SDK, gcc, dev packages, system headers/libs, cmake, ninja, etc. is needed
  • Building is as easy as running zig build (see: Building)
  • Libraries are written from scratch in Zig or provide Ziggified bindings to carefully selected C/C++ libraries
  • Uses native version of WebGPU API (mach/gpu) for cross-platfrom graphics and DirectX 12 for low-level graphics on Windows

I work on this project full-time and try to make a living from donations. If you like it, please consider supporting me. Thanks!

Cross-platfrom (Win/Lin/Mac) sample applications (native wgpu)

Some of the sample applications are listed below. More can be found in samples directory.

  1. physically based rendering (wgpu): This sample implements physically-based rendering (PBR) and image-based lighting (IBL) to achive realistic looking rendering results.

    physically based rendering (wgpu)

    zig build physically_based_rendering_wgpu-run

  2. bullet physics test (wgpu): This sample application demonstrates how to use full 3D physics engine in your Zig programs.

    bullet physics test (wgpu)

    zig build bullet_physics_test_wgpu-run

  3. procedural mesh (wgpu): This sample shows how to efficiently draw several procedurally generated meshes.

    procedural mesh wgpu (wgpu)

    zig build procedural_mesh_wgpu-run

Windows sample applications (DirectX 12)

If you are new to DirectX 12 graphics programming I recommend starting with intro applications.

  1. rasterization: This sample application shows how GPU rasterizes triangles in slow motion.

    rasterization

    zig build rasterization-run

  2. simple raytracer: This sample implements basic hybrid renderer. It uses rasterization to resolve primary rays and raytracing (DXR) for shadow rays.

    simple raytracer

    zig build simple_raytracer-run

  3. mesh shader test: This sample shows how to use DirectX 12 Mesh Shader.

    mesh shader test

    zig build mesh_shader_test-run

Building sample applications

To build all sample applications (assuming zig is in the PATH and Git LFS is installed):

  1. git clone https://github.com/michal-z/zig-gamedev.git
  2. cd zig-gamedev
  3. zig build

Build artifacts will show up in zig-out/bin folder.

zig build <sample_name> will build sample application named <sample_name>.

zig build <sample_name>-run will build and run sample application named <sample_name>.

To list all available sample names run zig build --help and navigate to Steps section.

Build options

All sample applications support the following build options:

  • -Drelease-safe=[bool] - Optimizations on and safety on
  • -Drelease-fast=[bool] - Optimizations on and safety off
  • -Dztracy-enable=[bool] - Tracy profiler zones enabled
  • -Dzgpu-dawn-from-source=[bool] - Build Dawn (WebGPU implementation) from source

Addidtional options for Windows applications:

  • -Denable-dx-debug=[bool] - Direct3D 12, Direct2D, DXGI debug layers enabled
  • -Denable-dx-gpu-debug=[bool] - Direct3D 12 GPU-Based Validation enabled (requires -Denable-dx-debug=true)
  • -Dzpix-enable=[bool] - PIX markers and events enabled

GitHub Sponsors

Thanks to all people who sponsor zig-gamedev project! In particular, these fine folks sponsor zig-gamedev for $25/month or more:

zig-gamedev's People

Contributors

briangold avatar damienfir avatar garettbass avatar gmodarelli avatar hazeycode avatar marler8997 avatar michal-z avatar mlarouche avatar mzet- avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.