Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraVoves committed Apr 11, 2024
0 parents commit 34b2e7d
Show file tree
Hide file tree
Showing 1,760 changed files with 1,210,226 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# LFS
*.png filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text

*.zig text eol=lf
141 changes: 141 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Test

permissions:
checks: write

on:
pull_request:
branches:
- main
- unstable
push:
branches:
- main

concurrency:
# Cancels pending runs when a PR gets updated.
group: ${{ github.head_ref || github.run_id }}-${{ github.actor }}
cancel-in-progress: true

jobs:
validation:
name: Validation
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- name: Read .zig-version
id: zigversion
uses: juliangruber/read-file-action@v1
with:
path: ./.zigversion
- name: Install Zig
uses: goto-bus-stop/setup-zig@v2
with:
version: ${{ steps.zigversion.outputs.content }}

- name: Lint
run: zig fmt --check .

x86-64-linux:
needs: ["validation"]
name: x86-64 Linux
runs-on: linux-large #ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- name: Prepare
run: sudo apt-get update && sudo apt-get install kcov libdbus-1-dev

- name: Read .zig-version
id: zigversion
uses: juliangruber/read-file-action@v1
with:
path: ./.zigversion
- name: Install Zig
uses: goto-bus-stop/setup-zig@v2
with:
version: ${{ steps.zigversion.outputs.content }}

- name: Build
shell: bash
run: zig build

- name: Build example 00
shell: bash
run: cd examples/00-minimal && zig build
- name: Build example 01
shell: bash
run: cd examples/01-minimal-zgui && zig build

x86-64-macos:
needs: ["validation"]
name: x86-64 Macos
runs-on: macos-13-large # macos-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- name: Read .zig-version
id: zigversion
uses: juliangruber/read-file-action@v1
with:
path: ./.zigversion
- name: Install Zig
uses: goto-bus-stop/setup-zig@v2
with:
version: ${{ steps.zigversion.outputs.content }}

- name: Build
shell: bash
run: zig build

- name: Build example 00
shell: bash
run: cd examples/00-minimal && zig build
- name: Build example 01
shell: bash
run: cd examples/01-minimal-zgui && zig build

x86-64-windows:
needs: ["validation"]
name: x86-64 Windows
runs-on: windows-large # windows-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- name: Read .zig-version
id: zigversion
uses: juliangruber/read-file-action@v1
with:
path: ./.zigversion
- name: Install Zig
uses: goto-bus-stop/setup-zig@v2
with:
version: ${{ steps.zigversion.outputs.content }}

- name: Build
shell: bash
run: zig build

- name: Build example 00
shell: bash
run: cd examples/00-minimal && zig build
- name: Build example 01
shell: bash
run: cd examples/01-minimal-zgui && zig build
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# ZIG
zig-cache
zig-out

# VSCode

# MacOS
*.DS_Store
.DS_Store
*.dylib

#examples/libs/zig-gamedev/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "examples/libs/zig-gamedev"]
path = examples/libs/zig-gamedev
url = https://github.com/michal-z/zig-gamedev.git
1 change: 1 addition & 0 deletions .zigversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.12.0-dev.3610+9d27f34d0
14 changes: 14 additions & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Authors

## Primary Authors

* __[Ondra Voves](https://github.com/OndraVoves)__

@OndraVoves is the current maintainer of the code.

## Other Contributors

The incomplete list of individuals below have provided patches or otherwise
contributed to the project prior to the project being hosted on GitHub. See the
GitHub commit log for a list of recent contributors. We would like to thank
everyone who has contributed to the project in any way.
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2024 Ondra Voves

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

1. You just DO WHAT THE FUCK YOU WANT TO.
85 changes: 85 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# ZBgfx

[![GitHub Actions](https://github.com/cyberegoorg/zbgfx/actions/workflows/test.yaml/badge.svg)](https://github.com/cyberegoorg/zbgfx/actions/workflows/test.yaml)

When [zig](https://github.com/ziglang/zig) meets [bgfx](https://github.com/bkaradzic/bgfx).

REMEMBER: This is only zig bindig for BGFX. For BGFX stuff goto [bgfx](https://github.com/bkaradzic/bgfx).

## Features

- [x] Zig api.
- [x] Compile as standard zig library.
- [x] `imgui` render backend. Use build option `imgui_include` to enable. ex. for zgui: `.imgui_include = zgui.path("libs").getPath(b),`
- [x] `shaderc` as build artifact.
- [x] Shader compile in `build.zig` to `*.bin.h`.
- [x] Shader compile in `build.zig` and embed as zig module. (this is zig equivalent of `*.bin.h`)
- [ ] WIP: Shader compile from code (in memory solution, no tmp files).
- [ ] WIP: [DebugDraw API](https://github.com/bkaradzic/bgfx/tree/master/examples/common/debugdraw)

## Warnings

- Shader compile api for building shaders in `build.zig` is first draft and need cleanup.

## Know problems

- On retina/hidpi display imgui rendering is broken but is probably simple to fix. (WIP)
- If you build shaders/app and see something like `run shaderc (shader.bin.h) stderr`.
Remember is not "true" error but only in debug build shaderc print some stuff to stderr and zig build catch it.

## Zig version

Minimal is `0.12.0`. But you know.. try your version and belive.
I am open to make some backward compatibility changes but not older version then `0.12.0`.

## Getting started

Copy `zbgfx` to a subdirectory of your project and add the following to your `build.zig.zon` .dependencies:

```zig
.zbgfx = .{ .path = "path/to/zbgfx" },
```

Then in your `build.zig` add:

```zig
pub fn build(b: *std.Build) void {
const exe = b.addExecutable(.{ ... });
const zbgfx = b.dependency("zbgfx", .{});
exe.root_module.addImport("zbgfx", zbgfx.module("zbgfx"));
exe.linkLibrary(zbgfx.artifact("bgfx"));
// This install shaderc to install dir
// For shader build in build =D check examples
// b.installArtifact(zbgfx.artifact("shaderc"));
}
```

## Usage

See examples for binding usage and [bgfx](https://github.com/bkaradzic/bgfx) for bgfx stuff.

## Examples

### [00-Minimal](examples/00-minimal/)

```sh
cd examples/minimal
zig build
```

```sh
zig-out/bin/minimal
```

### [01-Minimal-ZGui](examples/01-minimal-zgui/)

```sh
cd examples/minimal
zig build
```

```sh
zig-out/bin/minimal-zgui
```
Loading

0 comments on commit 34b2e7d

Please sign in to comment.