Giter Site home page Giter Site logo

mach-examples's Introduction

Mach engine & core examples

example-advanced-gen-texture-light example-boids example-textured-cube

More screenshots / example showcase: https://machengine.org/gpu

Run examples

git clone --recursive https://github.com/hexops/mach-examples
cd mach-examples/
zig build run-textured-cube

Use Mach engine in your own project

First run zig init-exe to create your project, then add Mach as a Git submodule:

git submodule add https://github.com/hexops/mach libs/mach

In your build.zig, use mach.App:

const std = @import("std");
const mach = @import("lib/mach/build.zig");

pub fn build(b: *std.build.Builder) !void {
    const target = b.standardTargetOptions(.{});
    const mode = b.standardReleaseOptions();

    const app = try mach.App.init(b, .{
        .name = "myapp",
        .src = "src/main.zig",
        .target = target,
        .deps = &[_]std.build.Pkg{},
    });
    app.setBuildMode(mode);
    try app.link(.{});
    app.install();

    const run_cmd = try app.run();
    run_cmd.dependOn(b.getInstallStep());

    const run_step = b.step("run", "Run the app");
    run_step.dependOn(run_cmd);
}

Your src/main.zig file can now const mach = @import("mach"); and you can run your code using zig build run.

Cross-compilation

You can cross-compile to every OS using:

zig build -Dtarget=x86_64-windows
zig build -Dtarget=x86_64-linux
zig build -Dtarget=x86_64-macos.12
zig build -Dtarget=aarch64-macos.12

WebAssembly examples

We don't yet support graphics in the browser (hexops/mach#90) but you can run the virtual piano example in the browser:

zig build run-sysaudio -Dtarget=wasm32-freestanding

Then navigate to http://localhost:8080/sysaudio.html and click inside the border area + type on your keyboard to play notes.

Join the community

Join the Mach community on Discord or Matrix to discuss this project, ask questions, get help, etc.

Issues

Issues are tracked in the main Mach repository.

Contributing

We're actively looking for contributors to port WebGPU examples to Zig, and are always looking for useful small examples we can include. If you think you might have one, definitely share it with us so we can consider including it!

mach-examples's People

Contributors

alichraghi avatar cmurtagh-lgtm avatar githubprankster avatar slimsag avatar tomasz-lisowski 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.