tuket / sokol-zig

Zig bindings for the sokol headers (https://github.com/floooh/sokol)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

build

Auto-generated Zig bindings for the sokol headers.

For Zig version 0.11.0-dev

NOTE: the zig-0.11.0 branch has been merged before Zig 0.11.0 is actually released because of a problem in the latest sokol headers involving if (@available(...)), which the sokol headers have started to use to conditionally support more recent Metal features.

Related projects:

BUILD

Supported platforms are: Windows, macOS, Linux (with X11)

On Linux install the following packages: libglu1-mesa-dev, mesa-common-dev, xorg-dev, libasound-dev (or generally: the dev packages required for X11, GL and ALSA development)

# just build:
> zig build
# build and run samples:
> zig build run-clear
> zig build run-triangle
> zig build run-quad
> zig build run-bufferoffsets
> zig build run-cube
> zig build run-noninterleaved
> zig build run-texcube
> zig build run-offscreen
> zig build run-instancing
> zig build run-mrt
> zig build run-saudio
> zig build run-sgl
> zig build run-sgl-context
> zig build run-sgl-points
> zig build run-debugtext
> zig build run-debugtext-print
> zig build run-debugtext-userfont
> zig build run-shapes

(also run zig build --help to inspect the build targets)

By default, the backend 3D API will be selected based on the target platform:

  • macOS: Metal
  • Windows: D3D11
  • Linux: GL

To force the GL backend on macOS or Windows, build with -Dgl=true:

> zig build -Dgl=true run-clear

The clear sample prints the selected backend to the terminal:

sokol-zig ➤ zig build -Dgl=true run-clear
Backend: .sokol.gfx.Backend.GLCORE33

Use as Library

Clone this repo into your project via git submodule add https://github.com/floooh/sokol-zig.git (for this example into a folder called lib within your project).

Add to your build.zig:

const sokol = @import("lib/sokol-zig/build.zig");

// ...
// pub fn build(b: *std.build.Builder) void {
// ...

const sokol_build = sokol.buildSokol(b, target, mode, .{}, "lib/sokol-zig/");

// ...
// const exe = b.addExecutable("demo", "src/main.zig");
// ...

exe.addPackagePath("sokol", "lib/sokol-zig/src/sokol/sokol.zig");
exe.linkLibrary(sokol_build);

About

Zig bindings for the sokol headers (https://github.com/floooh/sokol)


Languages

Language:C 69.4%Language:Zig 21.2%Language:Objective-C 9.0%Language:GLSL 0.3%