Giter VIP home page Giter VIP logo

delve-framework's Introduction

Delve Framework

Delve is a simple framework for building games written in Zig using Lua for scripting. Currently targets Zig 0.11.0

This is in early development and the api is still coming together, so be warned!

Screen Shot 2024-01-27 at 12 02 33 AM

Design Philosphy

Delve uses Zig to make writing cross platform games easy, and because it is easy to interop with the vast library of existing C/C++ game development libraries. Its main goal is to be as cross platform and unopinionated as much as possible, making it easy to switch out implementations as needed.

Libraries Used

  • Sokol for cross platform graphics and input
  • Lua for scripting using ziglua
  • stb_image for loading images
  • zaudio and zmesh from zig-gamedev

Scripting

The scripting manager can generate bindings for Lua automatically by reflecting on a zig file. Example:

// Find all public functions in `api/graphics.zig` and make them available to Lua under the module name `graphics`
bindZigLibrary("graphics", @import("api/graphics.zig"));

Delve will use the assets/main.lua Lua file for scripting unless given a new path on the command line during startup.

2D and 3D rendering

Rendering uses the Sokol framework to use modern, cross platform graphics APIs. Supports Vulkan, Metal, DirectX 11/12, OpenGL 3/ES, and WebGPU.

Batched 2d shape rendering:

delve-framework-2

GLTF mesh rendering:

delve-framework-8

Modules, all the way down

In the Delve framework most everything is a module, so that applications can use just the functionality they want as well as extending the framework as needed. As an example, the scripting layer is a module that registers other modules.

Additional Zig code can be registered as a Module to run during the game lifecycle:

const exampleModule = modules.Module {
    .name = "example-module",
    .init_fn = my_on_init,
    .tick_fn = my_on_tick,
    .draw_fn = my_on_draw,
    .cleanup_fn = my_on_cleanup,
};

try modules.registerModule(exampleModule);

Some example modules are included automatically to exercise some code paths, these live under src/examples and are good examples of how to start using the framework.

Building the examples

Clone the repo, then from a terminal:

# just build
zig build

# build and run an example
zig build run-audio
zig build run-clear
zig build run-debugdraw
zig build run-forest
zig build run-lua
zig build run-meshes
zig build run-sprites
zig build run-sprite-animation
zig build run-stresstest

Integrating into another Zig project

Add the framework to your build.zig.zon file as a dependency:

.{
    .name = "my_project",
    .version = "0.0.1",
    .dependencies = .{
        .delve = .{
            .url = "https://github.com/interrupt/delve-framework/archive/refs/tags/0.0.2.tar.gz",
            .hash = "1220b7bea202d8eb41a70b1f6fb5511d92d1fde891410de1cb8923b4ebf046f21e7c",
        },
    },
}

Then in your build.zig file, Delve can be included as a dependency:

const delve = b.dependency("delve", .{
    .target = target,
    .optimize = optimize,
});

...

exe.addModule("delve", delve.module("delve"));
exe.linkLibrary(delve.artifact("delve"));

delve-framework's People

Contributors

interrupt avatar joshuaskelly avatar

Stargazers

 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.