{"id":15099814,"url":"https://github.com/siddhantmadhur/zig-bgfx-sdl2","last_synced_at":"2026-01-06T20:42:53.455Z","repository":{"id":255633704,"uuid":"850957426","full_name":"siddhantmadhur/zig-bgfx-sdl2","owner":"siddhantmadhur","description":"Template to get started with using BGFX and SDL2 in Zig","archived":false,"fork":false,"pushed_at":"2024-09-14T02:13:17.000Z","size":20188,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T18:15:09.082Z","etag":null,"topics":["bgfx","graphics","sdl","sdl2","zig"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/siddhantmadhur.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-02T06:50:16.000Z","updated_at":"2024-09-14T02:13:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"ea896b1e-3c22-4572-baf0-2e7cc0ee4d56","html_url":"https://github.com/siddhantmadhur/zig-bgfx-sdl2","commit_stats":{"total_commits":26,"total_committers":1,"mean_commits":26.0,"dds":0.0,"last_synced_commit":"498ea7fd7dc9b7a8fa27dfb189c27b15d43f7327"},"previous_names":["siddhantmadhur/zig-bgfx-sdl2"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siddhantmadhur%2Fzig-bgfx-sdl2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siddhantmadhur%2Fzig-bgfx-sdl2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siddhantmadhur%2Fzig-bgfx-sdl2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siddhantmadhur%2Fzig-bgfx-sdl2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/siddhantmadhur","download_url":"https://codeload.github.com/siddhantmadhur/zig-bgfx-sdl2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245858879,"owners_count":20684057,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bgfx","graphics","sdl","sdl2","zig"],"created_at":"2024-09-25T17:27:51.006Z","updated_at":"2026-01-06T20:42:53.427Z","avatar_url":"https://github.com/siddhantmadhur.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BGFX w/ SDL2 in Zig\n\n![image](https://github.com/user-attachments/assets/c258dcdb-ff27-459f-af3f-88a442496023)\n\n\nThis 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.\n\n#### Libraries used:\n- [SDL2](https://www.libsdl.org/): This was very easy to get working as they upload the latest release compiled in a static library on their [github releases](https://github.com/libsdl-org/SDL/releases/latest).\n- [BGFX](https://bkaradzic.github.io/bgfx/overview.html): This was more cumbersome to download and get working as the resources online are very few, and further implementing it in Zig is even more sparse. \n\n\n## How to compile the static library\nI'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. \n\n### Prerequisites\n1. Zig\n2. [make](http://gnuwin32.sourceforge.net/packages/make.htm)\n\nThese are listed from the BGFX official documentation so I'd recommend installing them as well\n\n3. [coreutils](http://gnuwin32.sourceforge.net/packages/coreutils.htm)\n4. [libiconv](http://gnuwin32.sourceforge.net/packages/libiconv.htm)\n5. [libintl](http://gnuwin32.sourceforge.net/packages/libintl.htm)\n\n### Steps\n\n1. First download the three repositories required for bgfx\n\n```\ngit clone https://github.com/bkaradzic/bx.git\ngit clone https://github.com/bkaradzic/bimg.git\ngit clone https://github.com/bkaradzic/bgfx.git\n```\n\n2. Once these are downloaded, `cd` into the `bgfx` folder. This is where you'll be running the tools.\n3. Run the following command to generate the required makefiles\n```\n..\\bx\\tools\\bin\\windows\\genie.exe --gcc=mingw-gcc --with-sdl --with-tools gmake\n```\n4. `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.\n5. I didn't want to go through the process of installing and setting up MINGW so I used Zig's drop-in C and C++ compiler\n\n```\nmake config=release64 CC=\"zig cc\" CXX=\"zig c++\" AR=\"zig ar\" bx bimg bgfx shaderc\n```\nThis should take a few minutes and compile everything you need for the project in the `.build\\win64_mingw-gcc` folder\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiddhantmadhur%2Fzig-bgfx-sdl2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiddhantmadhur%2Fzig-bgfx-sdl2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiddhantmadhur%2Fzig-bgfx-sdl2/lists"}