siddhantmadhur/zig-bgfx-sdl2
Template to get started with using BGFX and SDL2 in Zig
This is a blank "hello triangle" project that links the static libraries for bgfx and SDL2 and renders a very basic triangle. I found it very difficult to accomplish this because I had very little knowledge about toolchains, libraries, or compiling C libraries, and then using them with Zig. Hopefully, this provides some ease of use. I've furthermore documented the process I used to set it up so I remember the exact steps I took.
I've only used these steps for Windows, and there could be better more efficient ways, but this is how I did it and got it working.
These are listed from the BGFX official documentation so I'd recommend installing them as well
git clone https://github.com/bkaradzic/bx.git
git clone https://github.com/bkaradzic/bimg.git
git clone https://github.com/bkaradzic/bgfx.git
cd
into the bgfx
folder. This is where you'll be running the tools...\bx\tools\bin\windows\genie.exe --gcc=mingw-gcc --with-sdl --with-tools gmake
cd
into the .build\projects\gmake-mingw-gcc
folder. If you are on an Arm chip, or a different operating system this will be different.make config=release64 CC="zig cc" CXX="zig c++" AR="zig ar" bx bimg bgfx shaderc
This should take a few minutes and compile everything you need for the project in the .build\win64_mingw-gcc
folder