GithubHelp home page GithubHelp logo

mjoerussell / zig-gamedev Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zig-gamedev/zig-gamedev

0.0 0.0 0.0 11.73 MB

Building game development ecosystem for @ziglang!

License: MIT License

Zig 6.78% HLSL 0.02% C++ 76.98% C 15.56% CMake 0.08% Objective-C 0.58%

zig-gamedev's Introduction

If you are new to low-level graphics programming or you would like to learn about zig-gamedev framework I recommend starting with intro applications.

zig-gamedev project

This repository contains a collection of sample applications and standalone libraries written in Zig programming language. Project is under active development, see Roadmap and Progress Reports for the details.

To get started on Windows/Linux/Mac try out triangle wgpu sample:

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

Some features:

  • Works on Windows, Linux and Mac (sample applications are WIP on Linux and Mac)
  • 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 or any other crap is needed
  • Building is as easy as running zig build (see: Building)
  • Uses mach/gpu (WebGPU) for cross-platfrom graphics, uses DirectX 12 for low-level graphics on Windows
  • Uses some great C/C++ libraries which are seamlessly built by zig cc compiler (see: libs/common/src/c)

Libraries we develop/maintain:

  • zmath - SIMD math library for game developers [cross-platform and standalone]
  • zbullet - Zig bindings and C API for Bullet physics library [cross-platform and standalone]
  • zmesh - Zig bindings for par shapes [cross-platform and standalone]
  • znoise - Zig bindings for FastNoiseLite [cross-platform and standalone]
  • zenet - Zig bindings for ENet [cross-platform and standalone]
  • ztracy - support for CPU profiling with Tracy [cross-platform and standalone]

Additionally for Windows applications we provide:

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

I build game development stuff in Zig full-time. If you like my project and my mission to promote the language, please consider supporting me.

Sample applications

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

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

    rasterization

  2. physically based rendering: This sample implements physically based shading and image based lighting to achive realistic looking rendering results.

    physically based rendering

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

    simple raytracer

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

    mesh shader test

  5. virtual physics lab: This sample application demonstrates how to use full 3D physics engine in your Zig programs.

    virtual physics lab

  6. audio playback test: This sample demonstrates how to decode .mp3 file using Microsoft Media Foundation and play it back using Windows Audio Session API (WASAPI).

    audio playback test

  7. DirectML convolution test: This sample demonstrates how to perform GPU-accelerated convolution operation using DirectML.

    directml convolution test

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.

Zig compiler consists of a single ~60MB .zip file that needs to be downloaded separately. Latest development build of the compiler must be used (master) you can download prebuilt binaries here.

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
  • -Denable-tracy=[bool] - Tracy profiler zones enabled
  • -Ddawn-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)
  • -Denable-pix=[bool] - PIX markers and events enabled

Examples

zig build triangle_wgpu-run -Drelease-fast=true

Requirements

On Windows, project uses DirectX 12 Agility SDK which allows to always use latest DirectX 12 features regardless of Windows version installed (this works from Windows 10 November 2019). In particular, following Windows versions are supported:

  • Windows 10 May 2021 (Build 19043) or newer
  • Windows 10 October 2020 (Build 19042.789+)
  • Windows 10 May 2020 (Build 19041.789+)
  • Windows 10 November 2019 (Build 18363.1350+)

GitHub Sponsors

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

  • mzet (mzet-)
  • Zig Software Foundation (ziglang)
  • Ian (LinuXY)
  • Simon A. Nielsen Knights (tauoverpi)
  • shintales (shintales)
  • Chris Heyes (hazeycode)

zig-gamedev's People

Contributors

gmodarelli avatar hazeycode avatar marler8997 avatar michal-z 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.