Giter Site home page Giter Site logo

not-nik / raylib-zig Goto Github PK

View Code? Open in Web Editor NEW
367.0 6.0 78.0 795 KB

Manually tweaked, auto-generated raylib bindings for zig. https://github.com/raysan5/raylib

License: MIT License

Zig 38.69% Shell 0.36% Python 1.52% GLSL 0.16% C 59.27%
raylib zig game-development gamedev bindings binding

raylib-zig's Introduction

logo

raylib-zig

Manually tweaked, auto-generated raylib bindings for zig.

Bindings tested on raylib version 5.0 and Zig 0.11.0/0.12.0-dev.1849+bb0f7d55e

Thanks to all the contributors for their help with this binding.

Example

const rl = @import("raylib");

pub fn main() anyerror!void {
    // Initialization
    //--------------------------------------------------------------------------------------
    const screenWidth = 800;
    const screenHeight = 450;

    rl.initWindow(screenWidth, screenHeight, "raylib-zig [core] example - basic window");
    defer rl.closeWindow(); // Close window and OpenGL context

    rl.setTargetFPS(60); // Set our game to run at 60 frames-per-second
    //--------------------------------------------------------------------------------------

    // Main game loop
    while (!rl.windowShouldClose()) { // Detect window close button or ESC key
        // Update
        //----------------------------------------------------------------------------------
        // TODO: Update your variables here
        //----------------------------------------------------------------------------------

        // Draw
        //----------------------------------------------------------------------------------
        rl.beginDrawing();
        defer rl.endDrawing();

        rl.clearBackground(rl.Color.white);

        rl.drawText("Congrats! You created your first window!", 190, 200, 20, rl.Color.light_gray);
        //----------------------------------------------------------------------------------
    }
}

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 an example, say basic_window run zig build basic_window

Building and using

Using raylib-zig's template

  • Execute project_setup.sh project_name, this will create a folder with the name specified
  • You can copy that folder anywhere you want and edit the source
  • Run zig build run at any time to test your project

In an existing project (e.g. created with zig init-exe)

Create a build.zig.zon and add raylib-zig as a dependency like so:

.{
    // ...
    .dependencies = .{
        .@"raylib-zig" = .{
            .url = "https://github.com/Not-Nik/raylib-zig/archive/devel.tar.gz",
            .hash = "12000000000000000000000000000000000000000000000000000000000000000000", // put the actual hash here
        },
    },
    // ...
}

Then add raylib-zig as a dependency and import it's modules and artifact in your build.zig:

const raylib_dep = b.dependency("raylib-zig", .{
    .target = target,
    .optimize = optimize,
});

const raylib = raylib_dep.module("raylib"); // main raylib module
const raylib_math = raylib_dep.module("raylib-math"); // raymath module
const rlgl = raylib_dep.module("rlgl"); // rlgl module
const raylib_artifact = raylib_dep.artifact("raylib"); // raylib C library

Now add the modules and artifact to your target as you would normally:

exe.linkLibrary(raylib_artifact);
exe.addModule("raylib", raylib);
exe.addModule("raylib-math", raylib_math);
exe.addModule("rlgl", rlgl);

If you additionally want to support Web as a platform with emscripten, you will need emcc.zig. Refer to raylib-zig's project template on how to use it

Exporting for web

To export your project for the web, first install emsdk. Once emsdk is installed, set it up by running

emsdk install latest

Find the folder where it's installed and run

zig build -Dtarget=wasm32-emscripten --sysroot [path to emsdk]/upstream/emscripten

once that is finished, the exported project should be located at zig-out/htmlout

When is the binding updated?

I plan on updating it every mayor release (2.5, 3.0, etc.). Keep in mind these are technically header files, so any implementation stuff should be updatable with some hacks on your side.

What needs to be done?

  • (Done) Set up a proper package build and a build script for the examples
  • Port all the examples
  • Member functions/initialisers

raylib-zig's People

Contributors

alanoliveira avatar alxhnr avatar anthony-63 avatar blazkowolf avatar bluesillybeard avatar franciscod avatar gertkeno avatar iacore avatar ivan-velickovic avatar jakeisnt avatar jdoleary avatar kaixi26 avatar keanbuyst avatar mbcrocci avatar not-nik avatar rcorre avatar sacredbirdman avatar seppelin avatar stalengd avatar sunarch avatar travisstaloch avatar tresmiur avatar tumberino avatar ve-nt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

raylib-zig's Issues

Feature request: bindings for Raylib `rlgl` OpenGL abstraction layer

rlgl

Raylib provides rlgl which is a cool abstraction yielding an OpenGL 1.1 "feeling" API.

Value proposition (or lack thereof)

This would be really cool to add to the existing Zig bindings in this repo since there's times the higher-level Raylib primitives don't do the job. Granted, this is rarely the case, but I recently ran into this scenario and I was looking to use some of these rlgl functions from this repo.


Apologies if this is not the forum for this kind of request. Thanks for the great work on providing a great Zig experience for Raylib.

how do I include other libs (web build)

As a zig beginner I find it unclear how I can link more libs into the web build part. (metal/os build did work fine)
Could comments or doc show a sample on this. (zflecs in my case)
I used the project_setup.sh as explained.

DrawTextureRec failing silently in Release builds

This is likely a zig C ABI problem.. but I'm throwing it here first because I'm worried if I post it to ziglang they will say its the library or wrapper at fault. This had me stumped for several hours! It is critical that you test this on any of the release builds, as it works fine in debug. I am using zig build -Drelease-small=true. I'm also running zig version 0.7.0+58241364c

usingnamespace @import("raylib");

pub const TextureDrawer = struct {
    width:f32,
    height:f32,
    pub fn GetRect(self:*TextureDrawer) Rectangle{
        return Rectangle{
            .x=0,.y=0,
            .width=self.width,
            .height=self.height};
    }
    pub fn Draw( self:*TextureDrawer ) void{
         DrawTextureRec(Tex,self.GetRect(),Vector2{.x=0,.y=0},WHITE);
    }
    pub fn DrawWithRect(self:*TextureDrawer,rect:Rectangle ) void {
        DrawTextureRec(Tex,rect,Vector2{.x=0,.y=0},WHITE);
    }
};

pub var Drawer = TextureDrawer{.width=64,.height=64};
pub var Tex : Texture2D = undefined;

pub fn main() anyerror!void
{
    const screenWidth = 800;
    const screenHeight = 450;
    InitWindow(screenWidth, screenHeight, "raylib-zig [core] example - basic window");
    Tex = LoadTexture("tiles.bmp");

    SetTargetFPS(60); 
    while (!WindowShouldClose())    
    {
        BeginDrawing();

        ClearBackground(WHITE);

        Drawer.Draw();  //DOES NOT WORK
        Drawer.DrawWithRect(Drawer.GetRect());  //THIS WORKS

        EndDrawing();
    }
    CloseWindow();  
}

So this is the absolute bare minimum code to show the problem. Basically if you call a function that returns a rectangle from inside a struct and pass it to DrawTextureRec it fails silently. I am way too dumb to try and diagnose what's happening here.

Some additional info that had me really scratching my head - If you do a print command inside the problematic function to check the contents of the rectangle, it works again.

    pub fn DrawWithPrint( self:*TextureDrawer ) void{
        var rect = self.GetRect();
        std.debug.print("Rect: {}",.{rect});
        DrawTextureRec(Tex,rect,Vector2{.x=0,.y=0},WHITE);
    }

Its some schrodinger's cat behavior, works only when observed.

Building examples on windows

I'm sure I'm just doing something wrong in the set up but something is going wrong when its pulling in the raylib module and compiling it. Here's an excerpt:

This is from just cloning the repo and following the 'getting started' steps to build the examples

attempting to fetch submodule(s)...
error(compilation): clang failed with stderr: In file included from C:\TSHEngine\Zig\raylib-zig\raylib\src\rglfw.c:54:
In file included from C:\folder\raylib-zig\raylib\src/external/glfw/src/context.c:30:
In file included from C:\folder\raylib-zig\raylib\src/external/glfw/src/internal.h:186:
In file included from C:\folder\raylib-zig\raylib\src/external/glfw/src/win32_platform.h:70:
C:\folder\raylib-zig\raylib\src\external\glfw\deps\mingw\xinput.h:227:26: error: a parameter list without types is only allowed in a function definition
In file included from C:\folder\raylib-zig\raylib\src\rglfw.c:54:
C:\folder\raylib-zig\raylib\src/external/glfw/src/context.c:407:10: warning: 'sscanf' is deprecated: This function or variable may be unsafe. Consider using sscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations]

Doesnt compile

Using zig version 0.10.0 I get a compile error out of the box:

zig build run 
C:\m_programs\zig\zig_0_10\lib\std\build.zig:2314:31: error: deprecated; use addIncludePath
    pub const addIncludeDir = @compileError("deprecated; use addIncludePath");
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
referenced by:
    addRaylib: c:\dev\mazetd\deps\raylib-zig\raylib\src\build.zig:38:19
    link: c:\dev\mazetd\deps\raylib-zig\lib.zig:18:27
    remaining reference traces hidden; use '-freference-trace' to see all reference traces


Compilation exited abnormally with code 1 at Tue Jan 17 15:05:36

Raylib has fixed this in raysan5/raylib@8f88c61 , could you update the submodule to include it?

loadFontFromMemory fontChars missing support for NULL

LoadFontFromMemory poor bindings

Font LoadFontFromMemory(const char *fileType, const unsigned char *fileData, int dataSize, int fontSize, int *fontChars, int glyphCount); 
// Load font from memory buffer, fileType refers to extension: i.e. '.ttf'

the parameter named fontChars int* is supported be null by raylib but not by our bindings, in serveral raylib example this varaible is set to 0 or NULL (is the same) and the behaviur when you do that is that it take all char from the first one.
in our bindings the parameter is a []i32 and i cant figure it out a workaround to set 0 or null

PS: the next paramenter make no sense if we send a slice in the first one, the second one must be the lenght of the slice

Use OS specific path separators in `build.zig`, and remove comptime parameters in `getModule`.

Currently, the build script uses lib/raylib-zig.zig.
We should replace that / with a return value from std.fs.path.join.

I also think the TODO comment in build.zig can be addressed without too much trouble.
Currently, I'm using trying to write my own build.zig instead of using the setup script, and I have this piece of code in my build script:

const paths = [2][]const u8{ "lib", "raylib-zig" };
const raylib_zig_path = try std.fs.path.join(allocator, &paths);
var raylib = rl.getModule(b, raylib_zig_path);

However, since the second parameter to getModule is comptime, I am unable to pass a runtime value to it.

If this project is open to contributions, I can raise a PR.

No Autocomplete For Zig LSP

Hello! Recently while using this library I noticed that the zig LSP was unable to find any of the function signatures for autocompletion. The type for the Raylib include is unknown and there are no autocomplete. I have included screenshots of both of these things below.

while searching for solutions I found another person who uploaded a youtube video had the same issue.

here is that video with the timestamp included.

I am using the stock LSP plugin for vscode and the latest stable release of zig. Any help is appreciated; thanks!

image

image

No implementation for adding Vectors ??

I have initialized Vector2 using .init() ;
I tried adding it to another Vector2 using + ;
This results in an error.

I have used Raylib before with rust and it has Vector2 + Vector2 implemented.

Is it not implemented for ZIG because it is impossible or by design?
Or am I missing something?

P.S. currently because of this I resorted to manually adding Vector2.x + Vector2.x and Vector2.y + Vector2.y.
P.S.S. Also rust raylib has a lot of useful methods for Vector2 implemented aka .dot product, .lerp, and so on.
Are these not implemented also in zig raylib? Or did I miss something?

`DrawTextEx` odd text size behaviour

Running into an issue when printing text using DrawTextEx. The font size is over ridden by the y member of the Vector2 struct. As you increase position.y the text size increases.

Not sure if this is a raylib issue, a zig issue, or a me issue.

Code Example

const font: raylib.Font = raylib.LoadFont("assets/fonts/Vermin Vibes 1989.ttf"); // or any other font

...

const x: f32 = 10;
const y: f32 = 10;
const position = raylib.Vector2{ .x = x, .y = y };

...

raylib.DrawTextEx(font, "Hello World", position, 8.0, 1.0, raylib.BLUE);

GDB Step Through

When I walk through DrawTextEx in GDB we can see the Vector2 somehow loses its y value and that value ends up shifting the fontSize parameter into the spacing parameter.

Before we enter DrawTextEx we can see that position is still `{x=10,y=10}

(gdb) p position
$1 = {x = 10, y = 10}

The call to enter position is wrong. The fontSize should be 8 and the spacing should be 1.

(gdb) s
DrawTextEx (font=..., text=0x20c702 <game-state-example.gameloop.anon_3209> "Hello World", position=..., fontSize=10, spacing=8, tint=...)
    at raylib-zig/raylib/src/rtext.c:1030

Looking at position from within DrawTextEx we can see that position.y has been set to 0

(gdb) p position
$2 = {x = 10, y = 0}

As we saw from the call to Draw Text Ex fontSize is 10 and spacing is 8. These should be 8 and 1 respectivly

(gdb) p fontSize
$3 = 10
(gdb) p spacing
$4 = 8

I cant tell if there is an issue with tint, the struct signature looks a little off.

(gdb) p tint
$5 = {r = 0 '\000', g = 121 'y', b = 241 '\361', a = 255 '\377'}
(gdb) 

GDB Disassembly

Disassembling the lead into the DrawTextEx function yields:

│  >0x2b5e42 <game-state-example.gameloop+466>      add    $0x8,%rax
0x2b5e46 <game-state-example.gameloop+470>      vmovss -0x8(%rbp),%xmm0
0x2b5e4b <game-state-example.gameloop+475>      vmovss -0x4(%rbp),%xmm1
0x2b5e50 <game-state-example.gameloop+480>      mov    -0xb275a(%rip),%esi        # 0x2036fc
0x2b5e56 <game-state-example.gameloop+486>      vmovups (%rax),%ymm2
0x2b5e5a <game-state-example.gameloop+490>      vmovups 0x10(%rax),%ymm3
0x2b5e5f <game-state-example.gameloop+495>      mov    %rsp,%rax
0x2b5e62 <game-state-example.gameloop+498>      vmovups %ymm3,0x10(%rax)                                                                                                   │
0x2b5e67 <game-state-example.gameloop+503>      vmovups %ymm2,(%rax)                                                                                                       │
0x2b5e6b <game-state-example.gameloop+507>      lea    -0xa9770(%rip),%rdi        # 0x20c702 <game-state-example.gameloop__anon_3209>     
│  >0x2b5e42 <game-state-example.gameloop+466>      add    $0x8,%rax
0x2b5e46 <game-state-example.gameloop+470>      vmovss -0x8(%rbp),%xmm0
0x2b5e4b <game-state-example.gameloop+475>      vmovss -0x4(%rbp),%xmm1
0x2b5e50 <game-state-example.gameloop+480>      mov    -0xb275a(%rip),%esi        # 0x2036fc
0x2b5e56 <game-state-example.gameloop+486>      vmovups (%rax),%ymm2
0x2b5e5a <game-state-example.gameloop+490>      vmovups 0x10(%rax),%ymm3
0x2b5e5f <game-state-example.gameloop+495>      mov    %rsp,%rax
0x2b5e62 <game-state-example.gameloop+498>      vmovups %ymm3,0x10(%rax)                                                                                                   │
0x2b5e67 <game-state-example.gameloop+503>      vmovups %ymm2,(%rax)                                                                                                       │
0x2b5e6b <game-state-example.gameloop+507>      lea    -0xa9770(%rip),%rdi        # 0x20c702 <game-state-example.gameloop__anon_3209> 
0x2b5e72 <game-state-example.gameloop+514>      vmovss -0xb278a(%rip),%xmm2        # 0x2036f0
0x2b5e7a <game-state-example.gameloop+522>      vmovss -0xb2796(%rip),%xmm3        # 0x2036ec
0x2b5e82 <game-state-example.gameloop+530>      vzeroupper
│  >0x2b5e85 <game-state-example.gameloop+533>      callq  0x35cbc0 <DrawTextEx>  
0x35cbc1 <DrawTextEx+1>         mov    %rsp,%rbp
0x35cbc4 <DrawTextEx+4>         sub    $0xc0,%rsp
0x35cbcb <DrawTextEx+11>        lea    0x10(%rbp),%rax
0x35cbcf <DrawTextEx+15>        mov    %rax,-0x90(%rbp)                                                                                                                    │
0x35cbd6 <DrawTextEx+22>        mov    %fs:0x28,%rcx
0x35cbdf <DrawTextEx+31>        mov    %rcx,-0x8(%rbp)                                                                                                                     │
0x35cbe3 <DrawTextEx+35>        vmovlpd %xmm0,-0x48(%rbp)                                                                                                                  │
0x35cbe8 <DrawTextEx+40>        mov    %esi,-0x50(%rbp)                                                                                                                    │
0x35cbeb <DrawTextEx+43>        mov    %rdi,-0x58(%rbp)                                                                                                                    │
0x35cbef <DrawTextEx+47>        vmovss %xmm1,-0x5c(%rbp)                                                                                                                   │
0x35cbf4 <DrawTextEx+52>        vmovss %xmm2,-0x60(%rbp) 

edit: extracted position to demonstrate issue via GDB

Streamlining `build.zig` for easier integration with Zig's Package Manager

To my knowledge, using this library requires you to clone it. However, I suspect there's a more efficient method to incorporate it as a dependency in build.zig.zon.

I implemented the following adjustments to make it work:

In build.zig.zon

.dependencies = .{
        .@"raylib-zig" = .{
            .url = "https://github.com/Not-Nik/raylib-zig/archive/f8735a8cc79db221d3c651c93778cfdb5066818d.tar.gz",
            .hash = "1220ec9abcca33f803b667c901c8d6e9686e2206aabb1ed6712926e457c7a61e1f60",
        },
        .raylib = .{
            .url = "https://github.com/raysan5/raylib/archive/5.0.tar.gz",
            .hash = "1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b",
        },
    },

raylib-zig's build.zig

// Get the directory of the lib
fn getPath() []const u8 {
    return std.fs.path.dirname(@src().file).?;
}

pub fn getModule(b: *std.Build, comptime rl_path: []const u8) *std.Build.Module {
   // ...
}

// Now I can just 'const raylib = rl.getModuleNoPath(b);'
pub fn getModuleNoPath(b: *std.Build) *std.Build.Module {
    if (b.modules.contains("raylib")) {
        return b.modules.get("raylib").?;
    }
    return b.addModule("raylib", .{ .source_file = .{ .path = comptime getPath() ++ "/lib/raylib-zig.zig" } });
}

Similarly for math:

pub fn getModuleNoPath(b: *std.Build) *std.Build.Module {
        const raylib = rl.getModuleNoPath(b);
        return b.addModule("raylib-math", .{
            .source_file = .{ .path = comptime getPath() ++ "/lib/raylib-zig-math.zig" },
            .dependencies = &.{.{ .name = "raylib-zig", .module = raylib }},
        });
    }

However, I've encountered an issue with getRaylib() as it requires adding the original raylib dependency, which necessitates a workaround to resolve.

Also, it’s better to use path.join rather than just sticking paths together with concatenation.

Offer to help: raygui support

Hi, I'd love to help add support for raygui bindings to this repo.

I'm quite new to zig but making progress quickly. I got raygui working in a fork of this repo. If you're in the raylib discord you can see my results here:

I think my first attempt isn't idiomatic but it works. As you can see in the above link, I had to import raylib again in order to get the raygui import working, so I'm sure there's a better way than what I did.

const c = @cImport({
    @cInclude("raylib.h");
    @cDefine("RAYGUI_IMPLEMENTATION", {});
    @cInclude("raygui.h");
});

Thoughts?

Error in Vector3Length while building examples

C:\Dev\Zig\raylib-zig>zig version
0.10.0-dev.1877+f3b3d7f20

C:\Dev\Zig\raylib-zig>zig build examples
C:\Dev\Zig\raylib-zig\lib\raylib-zig-math.zig:47:32: error: expected type expression, found 'const'
pub extern fn Vector3Length(v: const Vector3) f32;
                               ^
2d_camera...The following command exited with error code 1:
C:\Zig\zig.exe build-exe C:\Dev\Zig\raylib-zig\examples\core\2d_camera.zig C:\Dev\Zig\raylib-zig\zig-cache\o\5939d4ede160d8752b29f69d6ffb6f80\raylib.lib -lwinmm -lgdi32 -lopengl32 -lc -lwinmm -lgdi32 -lopengl32 --cache-dir C:\Dev\Zig\raylib-zig\zig-cache --global-cache-dir C:\Users\fviktor\AppData\Local\zig --name 2d_camera --pkg-begin raylib C:\Dev\Zig\raylib-zig\lib\raylib-zig.zig --pkg-end --pkg-begin raylib-math C:\Dev\Zig\raylib-zig\lib\raylib-zig-math.zig --pkg-end --enable-cache
error: the following build command failed with exit code 1:
C:\Dev\Zig\raylib-zig\zig-cache\o\c24318668343d4fd17995d66166b9eb6\build.exe C:\Zig\zig.exe C:\Dev\Zig\raylib-zig C:\Dev\Zig\raylib-zig\zig-cache C:\Users\fviktor\AppData\Local\zig examples

Building for WebAssembly

As the title says, is there any possibility building a project using raylib-zig to wasm ? Any examples of how to accomplish this?

Implement system-raylib flag

So unless I'm misreading the code, this flag is not implemented and there's currently no way to use the system raylib instead of a fresh download, yes?

(This is relevant to me as raylib doesn't seem to want to compile on MacOS as of an Xcode update a couple days ago, but I got it installed via Homebrew first.)

DrawTextureEx, DrawTexturePro, ect, not drawing

I was trying to draw scaled textures and I was not able to. While DrawTexture works, any of the other texture drawing methods that allow for scaling seem to be broken.

If I try this zig code:

const std = @import("std");
const rl = @import("raylib");

const window_width = 800;
const window_height = 600;

pub fn main() anyerror!void {
    rl.InitWindow(window_width, window_height, "Nemo Font Converter");
    rl.SetTargetFPS(60);

    var img = rl.GenImageChecked(512, 512, 12, 12, rl.RED, rl.BLUE);
    defer rl.UnloadImage(img);

    var tex = rl.LoadTextureFromImage(img);
    defer rl.UnloadTexture(tex);

    while (!rl.WindowShouldClose()) {
        rl.BeginDrawing();
        rl.ClearBackground(rl.WHITE);
        var pos = rl.Vector2{ .x = 0, .y = 0 };
        rl.DrawTextureEx(
            tex,
            pos,
            @as(f32, 0),
            @as(f32, 2),
            rl.WHITE,
        );

        rl.EndDrawing();
    }

    rl.CloseWindow();
}

I only get a while screen, while the same code in C gives me the correct result:

#include "raylib/src/raylib.h"

int main() {
    InitWindow(800, 600, "Textur test");
    SetTargetFPS(60);

    Image img = GenImageChecked(512, 512, 12, 12, RED, BLUE);

    Texture2D tex = LoadTextureFromImage(img);

    while (!WindowShouldClose()) {
        BeginDrawing();

        Vector2 pos = { .x = 0, .y = 0 };

        DrawTextureEx(tex, pos, 0, 2, WHITE);

        EndDrawing();
    }

    UnloadImage(img);
    UnloadTexture(tex);
}

I have tried with both system and compiled raylib and get the same results. I am using macOS:

INFO: Initializing raylib 4.0
INFO: DISPLAY: Device initialized successfully
INFO:     > Display size: 1920 x 1080
INFO:     > Screen size:  800 x 600
INFO:     > Render size:  800 x 600
INFO:     > Viewport offsets: 0, 0
INFO: GL: Supported extensions count: 43
INFO: GL: OpenGL device information:
INFO:     > Vendor:   Apple
INFO:     > Renderer: Apple M1
INFO:     > Version:  4.1 Metal - 76.3
INFO:     > GLSL:     4.10
❯ zig version
0.10.0-dev.378+40b3c9a59

where is raylib built from

I want to tweak some raylib modules, eg. rcamera (in c), where are the files compiled from? Thank you!

IsGamepadButtonXXX functions are using wrong enum

pub extern fn IsGamepadButtonPressed(gamepad: c_int, button: MouseButton) bool;
pub extern fn IsGamepadButtonDown(gamepad: c_int, button: MouseButton) bool;
pub extern fn IsGamepadButtonReleased(gamepad: c_int, button: MouseButton) bool;
pub extern fn IsGamepadButtonUp(gamepad: c_int, button: MouseButton) bool;

Hello guys,
All these gamepad function are using the MouseButton enumerator, I believe it should be GamepadButton

Tips on using with zigmod?

I'm trying to use raylib-zig managed via the zigmod package manager.

Here is my minimal reproduction repo.

Currently I'm getting the following errors:

❯ zigmod fetch && zig build
zig build-exe zig-raylib Debug native: error: error(link): undefined reference to symbol '_SetTargetFPS'
error(link):   first referenced in '/Users/noah/Git/zig-raylib/zig-cache/o/33bce2cd32849d3e46c909076dc84aa1/zig-raylib.o'
error(link): undefined reference to symbol '_ClearBackground'
error(link):   first referenced in '/Users/noah/Git/zig-raylib/zig-cache/o/33bce2cd32849d3e46c909076dc84aa1/zig-raylib.o'
error(link): undefined reference to symbol '_InitWindow'
error(link):   first referenced in '/Users/noah/Git/zig-raylib/zig-cache/o/33bce2cd32849d3e46c909076dc84aa1/zig-raylib.o'
error(link): undefined reference to symbol '_CloseWindow'
error(link):   first referenced in '/Users/noah/Git/zig-raylib/zig-cache/o/33bce2cd32849d3e46c909076dc84aa1/zig-raylib.o'
error(link): undefined reference to symbol '_WindowShouldClose'
error(link):   first referenced in '/Users/noah/Git/zig-raylib/zig-cache/o/33bce2cd32849d3e46c909076dc84aa1/zig-raylib.o'
error(link): undefined reference to symbol '_EndDrawing'
error(link):   first referenced in '/Users/noah/Git/zig-raylib/zig-cache/o/33bce2cd32849d3e46c909076dc84aa1/zig-raylib.o'
error(link): undefined reference to symbol '_DrawText'
error(link):   first referenced in '/Users/noah/Git/zig-raylib/zig-cache/o/33bce2cd32849d3e46c909076dc84aa1/zig-raylib.o'
error(link): undefined reference to symbol '_BeginDrawing'
error(link):   first referenced in '/Users/noah/Git/zig-raylib/zig-cache/o/33bce2cd32849d3e46c909076dc84aa1/zig-raylib.o'
error: UndefinedSymbolReference

zig build-exe zig-raylib Debug native: error: the following command exited with error code 1:
/Users/noah/.asdf/installs/zig/0.11.0/zig build-exe /Users/noah/Git/zig-raylib/src/main.zig --cache-dir /Users/noah/Git/zig-raylib/zig-cache --global-cache-dir /Users/noah/.cache/zig --name zig-raylib --mod raylib::/Users/noah/Git/zig-raylib/.zigmod/deps/git/github.com/Not-Nik/raylib-zig/lib/raylib-zig.zig --deps raylib --listen=- 
Build Summary: 0/3 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
└─ install zig-raylib transitive failure
   └─ zig build-exe zig-raylib Debug native failure
error: the following build command failed with exit code 1:
/Users/noah/Git/zig-raylib/zig-cache/o/ffdbe2a826d9cb195ad0cb1dca291adf/build /Users/noah/.asdf/installs/zig/0.11.0/zig /Users/noah/Git/zig-raylib /Users/noah/Git/zig-raylib/zig-cache /Users/noah/.cache/zig
error: Recipe `default` failed on line 6 with exit code 1

I've also tried including raylib-zig as a zigmod build-time depedency to no avail.

I know this isn't strictly related to raylib-zig, but I figured if I can get this working I can contribute back documentation to both zigmod and raylib-zig that others might benefit from. 😄

[Help wanted] Compile raylib on macOS

Currently compiling raylib on macOS is unsupported. The closest we ever got is this commit which segmentation faulted for at least two reasons:

  • The buffer passed to std.fmt.bufPrint is too small for the given string
  • Some unknown reason, fixing it will probably make compilation work

Compiling raylib's built-in version of GLFW will most likely never work, since it requires compilation of Objective-C code, however, we can use the system version of GLFW if present.
Help is much appreciated.

flags incorrectly converted in the python generator

the SetWindowState, ClearWindowState and SetConfigFlags functions are manually set to convert their flags argument to the ConfigFlags type

However, this is incorrect. These functions are desgined to take multiple flags not just one
Its UB in zig to cast to an enum from integer which doesn't represent one of the values

Because of this, trying to pass multiple flags at once to any of these will cause Zig to invoke UB (and even panic with safety checks enabled)

About function name style

Hi @Not-Nik, nice work you've being doing there!
This may be a little nitpicking, however, I wanna know are there any plan to make naming style more akin to zig's standard library?

InitWindow --> initWindow
SetTargetFPS --> setTargetFPS
WindowShouldClose --> windowShouldClose
CloseWindow --> closeWindow

I think it would nice to distinguish between functions and types more easily.

SetConfigFlags doesn't accept enum

When trying to use SetConfigFlags, a project will not build unless using Zig's @enumToInt function as it appears to accept only c_uint and not the defined ConfigFlags enum type.

Example code:```
// Doesn't build
rl.SetConfigFlags(rl.ConfigFlags.FLAG_WINDOW_UNFOCUSED);

// Works
rl.SetConfigFlags(@enumToInt(rl.ConfigFlags.FLAG_WINDOW_UNFOCUSED));

Getting an error when following readme instruction

As a beginner, I'm unable to get zig working following README:

  1. brew install zig
  2. git clone https://github.com/Not-Nik/raylib-zig
  3. cd raylib-zig && ./project-setup test && cd test
  4. zig build run

/build.zig:14:35: error: root struct of file 'raylib-zig.build' has no member named 'getArtifact'
const raylib_artifact = rl.getArtifact(b, target, optimize);
~~^~~~~~~~~~~~
referenced by:
runBuild__anon_6732: /opt/homebrew/Cellar/zig/0.11.0/lib/zig/std/Build.zig:1639:37
remaining reference traces hidden; use '-freference-trace' to see all reference traces

Still working on the fix, but I'm unfamiliar with Zig so raising this in case others have solved or run into this as well.

Running on Mac M1.

attempting to import both raylib and raylib-math fails

when wanting to use the math library, importing it like so:

const rl = @import("raylib");
const rlm = @import("raylib-math");

results in a failure to compile with the following error:
raylib-zig\lib\raylib-zig.zig:1:1: error: file exists in multiple modules

it does work in the example files (in camera2d.zig for example), but not when using it from outside the raylib-zig folder itself

Latest zig development version introduced breaking changes for build.zig

I am using latest zig version at the time of writing this (0.12.0-dev.2541+894493549).
Both raylib-zig's and the generated project's build.zig do not compile.

Person that opened #66 encountered some of the problems due to recent changes.

I tried to somehow patch build.zig by following the compiler errors but got lost along the way.
I'm also relatively new to zig.

This is as far as I've gotten. I'm not sure if it's even correct and otherwise I'm completely stumped.

diff --git a/build.zig b/build.zig
index f7b32d0..8d1b91d 100755
--- a/build.zig
+++ b/build.zig
@@ -84,30 +84,30 @@ pub fn getModule(b: *std.Build, comptime rl_path: []const u8) *std.Build.Module
     if (b.modules.contains("raylib")) {
         return b.modules.get("raylib").?;
     }
-    return b.addModule("raylib", .{ .source_file = .{ .path = rl_path ++ "/lib/raylib-zig.zig" } });
+    return b.addModule("raylib", .{ .root_source_file = .{ .path = rl_path ++ "/lib/raylib-zig.zig" } });
 }
 
 fn getModuleInternal(b: *std.Build) *std.Build.Module {
     if (b.modules.contains("raylib")) {
         return b.modules.get("raylib").?;
     }
-    return b.addModule("raylib", .{ .source_file = .{ .path = "lib/raylib-zig.zig" } });
+    return b.addModule("raylib", .{ .root_source_file = .{ .path = "lib/raylib-zig.zig" } });
 }
 
 pub const math = struct {
     pub fn getModule(b: *std.Build, comptime rl_path: []const u8) *std.Build.Module {
         const raylib = rl.getModule(b, rl_path);
         return b.addModule("raylib-math", .{
-            .source_file = .{ .path = rl_path ++ "/lib/raylib-zig-math.zig" },
+            .root_source_file = .{ .path = rl_path ++ "/lib/raylib-zig-math.zig" },
             .dependencies = &.{.{ .name = "raylib-zig", .module = raylib }},
         });
     }
 
     fn getModuleInternal(b: *std.Build) *std.Build.Module {
-        const raylib = rl.getModuleInternal(b);
+        //const raylib = rl.getModuleInternal(b);
         return b.addModule("raylib-math", .{
-            .source_file = .{ .path = "lib/raylib-zig-math.zig" },
-            .dependencies = &.{.{ .name = "raylib-zig", .module = raylib }},
+            .root_source_file = .{ .path = "lib/raylib-zig-math.zig" },
+            //.dependencies = &.{.{ .name = "raylib-zig", .module = raylib }},
         });
     }
 };
@@ -185,11 +185,11 @@ pub fn build(b: *std.Build) !void {
     const raylib_math = rl.math.getModuleInternal(b);
 
     for (examples) |ex| {
-        if (target.getOsTag() == .emscripten) {
-            const exe_lib = compileForEmscripten(b, ex.name, ex.path, target, optimize);
-            exe_lib.addModule("raylib", raylib);
-            exe_lib.addModule("raylib-math", raylib_math);
-            const raylib_lib = getRaylib(b, target, optimize);
+        if (target.result.os.tag == .emscripten) {
+            const exe_lib = compileForEmscripten(b, ex.name, ex.path, target.query, optimize);
+            exe_lib.root_module.addImport("raylib", raylib);
+            exe_lib.root_module.addImport("raylib-math", raylib_math);
+            const raylib_lib = getRaylib(b, target.query, optimize);
 
             // Note that raylib itself isn't actually added to the exe_lib
             // output file, so it also needs to be linked with emscripten.
@@ -209,9 +209,9 @@ pub fn build(b: *std.Build) !void {
                 .optimize = optimize,
                 .target = target,
             });
-            rl.link(b, exe, target, optimize);
-            exe.addModule("raylib", raylib);
-            exe.addModule("raylib-math", raylib_math);
+            rl.link(b, exe, target.query, optimize);
+            exe.root_module.addImport("raylib", raylib);
+            exe.root_module.addImport("raylib-math", raylib_math);
             const run_cmd = b.addRunArtifact(exe);
             const run_step = b.step(ex.name, ex.desc);
             run_step.dependOn(&run_cmd.step);

Error: Use of undeclared identifier 'L_tmpnam'

Hello, I've just cloned the repo and executed zig build examples, encountering the following error:

raylib.zig build-lib raylib Debug native-native: error: error(compilation): clang failed with stderr: In file included from /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/rtext.c:68:
/usr/include/stdio.h:205:27: error: use of undeclared identifier 'L_tmpnam'
/usr/include/stdio.h:210:33: error: use of undeclared identifier 'L_tmpnam'

error(compilation): clang failed with stderr: In file included from /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/rglfw.c:61:
In file included from /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/external/glfw/src/init.c:30:
In file included from /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/external/glfw/src/internal.h:331:
In file included from /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/external/glfw/src/platform.h:62:
In file included from /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/external/glfw/src/x11_platform.h:36:
In file included from /usr/include/X11/Xcursor/Xcursor.h:26:
/usr/include/stdio.h:205:27: error: use of undeclared identifier 'L_tmpnam'
/usr/include/stdio.h:210:33: error: use of undeclared identifier 'L_tmpnam'
In file included from /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/rglfw.c:87:
/home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/external/glfw/src/posix_poll.c:29:9: warning: '_GNU_SOURCE' macro redefined [-Wmacro-redefined]
<command line>:4:9: note: previous definition is here

error(compilation): clang failed with stderr: In file included from /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/rmodels.c:56:
/usr/include/stdio.h:205:27: error: use of undeclared identifier 'L_tmpnam'
/usr/include/stdio.h:210:33: error: use of undeclared identifier 'L_tmpnam'
In file included from /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/rmodels.c:111:
/home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/external/par_shapes.h:1133:32: warning: implicit conversion from 'int' to 'float' changes value from 2147483647 to 2147483648 [-Wimplicit-const-int-float-conversion]
/usr/include/stdlib.h:87:18: note: expanded from macro 'RAND_MAX'

error(compilation): clang failed with stderr: In file included from /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/rcore.c:95:
/usr/include/stdio.h:205:27: error: use of undeclared identifier 'L_tmpnam'
/usr/include/stdio.h:210:33: error: use of undeclared identifier 'L_tmpnam'

error(compilation): clang failed with stderr: In file included from /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/utils.c:48:
/usr/include/stdio.h:205:27: error: use of undeclared identifier 'L_tmpnam'
/usr/include/stdio.h:210:33: error: use of undeclared identifier 'L_tmpnam'

error(compilation): clang failed with stderr: In file included from /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/rtextures.c:79:
/usr/include/stdio.h:205:27: error: use of undeclared identifier 'L_tmpnam'
/usr/include/stdio.h:210:33: error: use of undeclared identifier 'L_tmpnam'

error(compilation): clang failed with stderr: In file included from /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/raudio.c:176:
In file included from /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/external/miniaudio.h:3857:
In file included from /usr/include/pthread.h:21:
/usr/include/features.h:478:9: warning: '__GLIBC_MINOR__' macro redefined [-Wmacro-redefined]
<command line>:1:9: note: previous definition is here
In file included from /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/raudio.c:176:
In file included from /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/external/miniaudio.h:11447:
/usr/include/stdio.h:205:27: error: use of undeclared identifier 'L_tmpnam'
/usr/include/stdio.h:210:33: error: use of undeclared identifier 'L_tmpnam'


raylib.zig build-lib raylib Debug native-native: error: the following command failed with 7 compilation errors:
/nix/store/mnwwkbzsbxpndxxilby0ji6qc5nf037m-zig-0.11.0/bin/zig build-lib -cflags -std=gnu99 -D_GNU_SOURCE -DGL_SILENCE_DEPRECATION=199309L -- /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/rcore.c /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/utils.c -cflags -std=gnu99 -D_GNU_SOURCE -DGL_SILENCE_DEPRECATION=199309L -- /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/raudio.c -cflags -fno-sanitize=undefined -std=gnu99 -D_GNU_SOURCE -DGL_SILENCE_DEPRECATION=199309L -- /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/rmodels.c -cflags -std=gnu99 -D_GNU_SOURCE -DGL_SILENCE_DEPRECATION=199309L -- /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/rshapes.c -cflags -std=gnu99 -D_GNU_SOURCE -DGL_SILENCE_DEPRECATION=199309L -- /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/rtext.c -cflags -std=gnu99 -D_GNU_SOURCE -DGL_SILENCE_DEPRECATION=199309L -- /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/rtextures.c -cflags -std=gnu99 -D_GNU_SOURCE -DGL_SILENCE_DEPRECATION=199309L -- /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/rglfw.c -lGL -lX11 -lc --cache-dir /home/miouzora/perso/Curve/raylib-zig/zig-cache --global-cache-dir /home/miouzora/.cache/zig --name raylib -static -target native-native -mcpu x86_64+adx+aes+avx+avx2+bmi+bmi2+clflushopt+clwb+cx16+f16c+fma+fsgsbase+gfni+invpcid+lzcnt+movbe+movdir64b+movdiri+pclmul+popcnt+prfchw+rdpid+rdrnd+rdseed+sahf+sha+shstk+sse3+sse4_1+sse4_2+ssse3+vaes+vpclmulqdq+waitpkg+xsave+xsavec+xsaveopt+xsaves -I /home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/external/glfw/include -I /usr/include -D PLATFORM_DESKTOP -L /usr/lib --listen=- 
Build Summary: 1/4 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
└─ install raylib transitive failure
   └─ zig build-lib raylib Debug native-native 7 errors
/home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/rtext.c:1:1: error: unable to build C object: clang exited with code 1
/home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/rglfw.c:1:1: error: unable to build C object: clang exited with code 1
/home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/rmodels.c:1:1: error: unable to build C object: clang exited with code 1
/home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/rcore.c:1:1: error: unable to build C object: clang exited with code 1
/home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/utils.c:1:1: error: unable to build C object: clang exited with code 1
/home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/rtextures.c:1:1: error: unable to build C object: clang exited with code 1
/home/miouzora/.cache/zig/p/1220c28847ca8e8756734ae84355802b764c9d9cf4de057dbc6fc2b15c56e726f27b/src/raudio.c:1:1: error: unable to build C object: clang exited with code 1

Zig version is: 0.11.0
Commit: 068f9e18168b986de0858b25e7adec3e212a3726

disable exit key

Currently, this is required to disable the exit key:

ray.SetExitKey(@ptrCast(*const ray.KeyboardKey, &@as(c_int, 0)).*);

This would be nicer if the KeyboardKey enum was non-exhaustive, then it would be,

ray.SetExitKey(@intToEnum(ray.KeyboardKey, 0));

or if KeyboardKey had a null option,

ray.SetExitKey(.KEY_NULL);

Error in build.zig

Kindly update the build.zig file. Most of the functions were already deprecated or changed.

Functions accepting slices sometimes redundantly also take their length

raylib functions often take an array and it's length as arguments. This is fine in C, because it doesn't have a concept of "fat-pointers", or "slices", but on the Zig side we try to map these array/length pairs to slices wherever possible.

This affects all of the following:

  • setWindowIcons
  • saveFileData
  • exportDataAsCode
  • compressData
  • decompressData
  • encodeDataBase64
  • loadImageFromMemory
  • loadFontFromMemory
  • loadFontData
  • drawMeshInstanced
  • unloadModelAnimations
  • loadWaveFromMemory
  • loadMusicStreamFromMemory
  • drawLineStrip
  • drawTriangleFan
  • drawTriangleStrip
  • checkCollisionPointPoly
  • loadFontEx
  • genImageFontAtlas
  • unloadFontData
  • drawTextCodepoints
  • loadUTF8
  • textJoin
  • drawTriangleStrip3D

However, I would like to postpone further fixes until Zig 0.11.0 is released and #48 is merged, so that I don't have to maintain two branches and push everything twice.

Apps crash when functions that return arrays, return null pointers

Sometimes raylib functions return NULL. This is mostly fine in pure C, because raylib is designed around this; it handles these null values properly. With Zig's ptrCast, however, it is undefined behaviour to cast a null pointer to a non-optional pointer and it checks this in debug builds, resulting in panics and crashes.

This affects all of the following:

  • loadFileData
  • loadImageColors
  • loadImagePalette
  • loadFontData (possibly, might never happen because its inputs can't be null from the Zig side)
  • loadCodepoints
  • loadMaterials
  • loadModelAnimations

Other functions returning arrays would either crash (segfault) before returning, because they use the arrays they return, or simply never return null pointers.

One simple way to address this, is to add an error type to each of these functions and check for null pointers. I am pretty sure that this would not affect the raylib feel of the binding, because if you've used these functions in C you are either an advanced user (font data, codepoints, extra materials, animations) or needed to check for null pointers anyways (file data).

Either way, I would like to postpone these fixes until Zig 0.11.0 is released and #48 is merged, so that I don't have to maintain two branches and push everything twice.

Support for Zig 0.11.x

As per title. The package does not currently support Zig version 0.11.x. I think most of the changes would be related to the Zig build system.

I could look at this if you would be willing to accept a PR? It might warrant it's own branch since 0.11.x is not officially out yet.

Building examples

Hi, I have tried using this library, here are the issues I've had with latest zig dev:

first , there is a compilation error in lib.zig line 65 something to do with the \ lines ,
C:\zigprojects\zigraylib\raylib-zig\lib.zig:65:27: error: expected ',', found invalid bytes
\Warning:
^
C:\zigprojects\zigraylib\raylib-zig\lib.zig:66:72: note: invalid byte: 'd'
\Unable to fetch git submodule(s) Assuming package folder is not under

so I changed that to a simple string, and it seemed to work.

Now when I do zig build examples I get the error:C:\zigprojects\zigraylib\raylib-zig\examples\core\basic_window.zig:17:5: error: use of undeclared identifier 'InitWindow'
InitWindow(screenWidth, screenHeight, "raylib-zig [core] example - basic window");

I haven't changed anything, not sure if I"m doing something wrong. I see on top of the file the usingnamespace @import("raylib");

(i'm developing on windows)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.