{"id":13626676,"url":"https://github.com/Not-Nik/raylib-zig","last_synced_at":"2025-04-16T15:31:25.792Z","repository":{"id":37010006,"uuid":"240681302","full_name":"Not-Nik/raylib-zig","owner":"Not-Nik","description":"Manually tweaked, auto-generated raylib bindings for zig. https://github.com/raysan5/raylib","archived":false,"fork":false,"pushed_at":"2024-10-18T11:22:29.000Z","size":1092,"stargazers_count":668,"open_issues_count":15,"forks_count":119,"subscribers_count":9,"default_branch":"devel","last_synced_at":"2024-11-05T07:34:21.882Z","etag":null,"topics":["binding","bindings","game-development","gamedev","raylib","zig","zig-package"],"latest_commit_sha":null,"homepage":"","language":"Zig","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/Not-Nik.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}},"created_at":"2020-02-15T09:58:13.000Z","updated_at":"2024-11-04T20:30:15.000Z","dependencies_parsed_at":"2024-01-17T21:23:01.900Z","dependency_job_id":"70519fe6-92fb-4958-b945-19197e36cc2a","html_url":"https://github.com/Not-Nik/raylib-zig","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Not-Nik%2Fraylib-zig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Not-Nik%2Fraylib-zig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Not-Nik%2Fraylib-zig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Not-Nik%2Fraylib-zig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Not-Nik","download_url":"https://codeload.github.com/Not-Nik/raylib-zig/tar.gz/refs/heads/devel","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223716679,"owners_count":17191090,"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":["binding","bindings","game-development","gamedev","raylib","zig","zig-package"],"created_at":"2024-08-01T21:02:26.222Z","updated_at":"2025-04-16T15:31:25.785Z","avatar_url":"https://github.com/Not-Nik.png","language":"Zig","readme":"![logo](https://github.com/Not-Nik/raylib-zig/raw/devel/logo/logo.png)\n\n# raylib-zig\n\nManually tweaked, auto-generated [raylib](https://github.com/raysan5/raylib) bindings for zig.\n\nBindings tested on raylib version 5.6-dev and Zig 0.14.0\n\nThanks to all the [contributors](https://github.com/Not-Nik/raylib-zig/graphs/contributors) for their help with this\nbinding.\n\n## Example\n\n```zig\nconst rl = @import(\"raylib\");\n\npub fn main() anyerror!void {\n    // Initialization\n    //--------------------------------------------------------------------------------------\n    const screenWidth = 800;\n    const screenHeight = 450;\n\n    rl.initWindow(screenWidth, screenHeight, \"raylib-zig [core] example - basic window\");\n    defer rl.closeWindow(); // Close window and OpenGL context\n\n    rl.setTargetFPS(60); // Set our game to run at 60 frames-per-second\n    //--------------------------------------------------------------------------------------\n\n    // Main game loop\n    while (!rl.windowShouldClose()) { // Detect window close button or ESC key\n        // Update\n        //----------------------------------------------------------------------------------\n        // TODO: Update your variables here\n        //----------------------------------------------------------------------------------\n\n        // Draw\n        //----------------------------------------------------------------------------------\n        rl.beginDrawing();\n        defer rl.endDrawing();\n\n        rl.clearBackground(.white);\n\n        rl.drawText(\"Congrats! You created your first window!\", 190, 200, 20, .light_gray);\n        //----------------------------------------------------------------------------------\n    }\n}\n```\n\n## Building the examples\n\nTo build all available examples simply `zig build examples`. To list available examples run `zig build --help`. If you\nwant to run an example, say `basic_window` run `zig build basic_window`\n\n## Building and using\n\n### Using raylib-zig's template\n\n* Execute `project_setup.sh project_name`, this will create a folder with the name specified\n* You can copy that folder anywhere you want and edit the source\n* Run `zig build run` at any time to test your project\n\n### In an existing project (e.g. created with `zig init`)\n\nDownload and add raylib-zig as a dependency by running the following command in your project root:\n\n```\nzig fetch --save git+https://github.com/Not-Nik/raylib-zig#devel\n```\n\nThen add raylib-zig as a dependency and import its modules and artifact in your `build.zig`:\n\n```zig\nconst raylib_dep = b.dependency(\"raylib_zig\", .{\n    .target = target,\n    .optimize = optimize,\n});\n\nconst raylib = raylib_dep.module(\"raylib\"); // main raylib module\nconst raygui = raylib_dep.module(\"raygui\"); // raygui module\nconst raylib_artifact = raylib_dep.artifact(\"raylib\"); // raylib C library\n```\n\nNow add the modules and artifact to your target as you would normally:\n\n```zig\nexe.linkLibrary(raylib_artifact);\nexe.root_module.addImport(\"raylib\", raylib);\nexe.root_module.addImport(\"raygui\", raygui);\n```\n\nIf you additionally want to support Web as a platform with emscripten, you will need to use `emcc.zig` by importing\nraylib-zig's build script with `const rlz = @import(\"raylib_zig\");` and then accessing its functions with `rlz.emcc`.\nRefer to raylib-zig's project template on how to use them.\n\n### Passing build options\n\nraylib allows customisations of certain parts of its build process such as choosing an OpenGL version, building as a\nshared library or not including certain modules. You can optionally pass these options to raylib-zig dependency like so\n\n```zig\nconst raylib_dep = b.dependency(\"raylib_zig\", .{\n    .target = target,\n    .optimize = optimize,\n    .shared = true, // Build raylib as a shared library\n    .opengl_version = rlz.OpenglVersion.gl_2_1, // Use OpenGL 2.1 (requires importing raylib-zig's build script)\n});\n```\n\n### Defining feature macros\n\nraylib lets the user enable and disable options for different features, loading different file formats for images,\nfonts, 3D models and audio, linkage variants. You can specify these options for your raylib-zig build by defining the\ncorresponding C macro before you link with it, e.g.:\n\n```zig\nraylib_artifact.root_module.addCMacro(\"SUPPORT_FILEFORMAT_JPG\", \"\");\n```\n\n## Exporting for web\n\nTo export your project for the web, first install emsdk.\nOnce emsdk is installed, set it up by running\n\n`emsdk install latest`\n\nFind the folder where it's installed and run\n\n`zig build -Dtarget=wasm32-emscripten --sysroot [path to emsdk]/upstream/emscripten`\n\nonce that is finished, the exported project should be located at `zig-out/htmlout`\n\n### When is the binding updated?\n\nI plan on updating it every mayor release (2.5, 3.0, etc.). Keep in mind these are technically header files, so any\nimplementation stuff should be updatable with some hacks on your side.\n\n### What needs to be done?\n\n+ _(Done)_ Set up a proper package build and a build script for the examples\n+ Port all the examples\n+ Member functions/initialisers\n","funding_links":[],"categories":["Game Development \u0026 Graphics","Libraries","Zig"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNot-Nik%2Fraylib-zig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FNot-Nik%2Fraylib-zig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNot-Nik%2Fraylib-zig/lists"}