From eba6c5392f2e0bff5e39ab9f97b29af11990245a Mon Sep 17 00:00:00 2001 From: Not-Nik Date: Sat, 8 Jan 2022 23:18:09 +0100 Subject: [PATCH] Update versions --- ReadMe.md | 40 +++++++++++++++------------------- build.zig | 2 +- examples/core/basic_window.zig | 3 +-- lib/raylib-zig.zig | 2 +- 4 files changed, 20 insertions(+), 27 deletions(-) diff --git a/ReadMe.md b/ReadMe.md index bdef2a9..1e53a76 100755 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,10 +1,10 @@ -![logo](https://github.com/Not-Nik/raylib-zig/blob/master/logo/logo.png) +![logo](https://github.com/Not-Nik/raylib-zig/raw/devel/logo/logo.png) # raylib-zig Manually tweaked, auto generated [raylib](https://github.com/raysan5/raylib) bindings for zig. -Bindings tested on raylib version 3.7 and Zig 0.9.0-dev +Bindings tested on raylib version 4.0.0-dev and Zig 0.9.0 Thanks to jessrud, mbcrocci, rcorre, Gertkeno and sacredbirdman for their contributions to this binding. @@ -15,51 +15,45 @@ The binding currently only supports a subset of raylib. For more information rea We can copy the default example with some minor changes: ```zig -usingnamespace @import("raylib"); +const rl = @import("raylib"); -pub fn main() anyerror!void -{ +pub fn main() anyerror!void { // Initialization //-------------------------------------------------------------------------------------- const screenWidth = 800; const screenHeight = 450; - InitWindow(screenWidth, screenHeight, "MyWindow"); + rl.InitWindow(screenWidth, screenHeight, "MyWindow"); - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + rl.SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key - { + while (!rl.WindowShouldClose()) { // Detect window close button or ESC key + // Update + //---------------------------------------------------------------------------------- + // TODO: Update your variables here + //---------------------------------------------------------------------------------- + // Draw //---------------------------------------------------------------------------------- - BeginDrawing(); + rl.BeginDrawing(); - ClearBackground(WHITE); + rl.ClearBackground(rl.WHITE); - DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY); + rl.DrawText("Congrats! You created your first window!", 190, 200, 20, rl.LIGHTGRAY); - EndDrawing(); + rl.EndDrawing(); //---------------------------------------------------------------------------------- } // De-Initialization //-------------------------------------------------------------------------------------- - CloseWindow(); // Close window and OpenGL context + rl.CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- } ``` -## Technical restrictions - -Due to zig being a relatively new language it does [not have full C ABI support](https://github.com/ziglang/zig/issues/1481) at the moment. For use that mainly means we -can't use any functions that return structs that are less than 16 bytes large. Here is an incomplete list of some functions affected by this: - -+ DrawCircleV -+ DrawRectangleRec -+ DrawModel and all its variations - ## Building the examples To build all available examples simply `zig build examples`. To list available examples run `zig build --help`. If you want to run and examples, say `basic_window` diff --git a/build.zig b/build.zig index 0dc3824..ff3f354 100755 --- a/build.zig +++ b/build.zig @@ -1,6 +1,6 @@ // // build -// Zig version: 0.6.0 +// Zig version: 0.9.0 // Author: Nikolas Wipper // Date: 2020-02-15 // diff --git a/examples/core/basic_window.zig b/examples/core/basic_window.zig index 5a5eb0a..2451ece 100755 --- a/examples/core/basic_window.zig +++ b/examples/core/basic_window.zig @@ -19,8 +19,7 @@ pub fn main() anyerror!void { //-------------------------------------------------------------------------------------- // Main game loop - while (!rl.WindowShouldClose()) // Detect window close button or ESC key - { + while (!rl.WindowShouldClose()) { // Detect window close button or ESC key // Update //---------------------------------------------------------------------------------- // TODO: Update your variables here diff --git a/lib/raylib-zig.zig b/lib/raylib-zig.zig index 05a86ec..b7025c6 100755 --- a/lib/raylib-zig.zig +++ b/lib/raylib-zig.zig @@ -1,6 +1,6 @@ // // raylib-zig -// Zig version: +// Zig version: 0.9.0 // Author: Nikolas Wipper // Date: 2020-02-15 //