Giter Site home page Giter Site logo

ceigey / raylib-zig Goto Github PK

View Code? Open in Web Editor NEW

This project forked from not-nik/raylib-zig

0.0 0.0 0.0 61 KB

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

License: MIT License

Zig 98.71% Shell 1.29%

raylib-zig's Introduction

raylib-zig

Manually tweaked, auto generated raylib bindings for zig.
Bindings tested on raylib version 2.6

Example

We can copy the default example with some minor changes:

usingnamespace @import("raylib");

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

    InitWindow(screenWidth, screenHeight, c"MyWindow");

    SetTargetFPS(60);               // Set our game to run at 60 frames-per-second
    //--------------------------------------------------------------------------------------

    // Main game loop
    while (!WindowShouldClose())    // Detect window close button or ESC key
    {
        // Draw
        //----------------------------------------------------------------------------------
        BeginDrawing();

            ClearBackground(WHITE);

            DrawText(c"Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);

        EndDrawing();
        //----------------------------------------------------------------------------------
    }

    // De-Initialization
    //--------------------------------------------------------------------------------------
    CloseWindow();        // Close window and OpenGL context
    //--------------------------------------------------------------------------------------
}

Technical restrictions

Due to zig being a relatively new language it does not have full C ABI support 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 run zig build basic_window

Building and using

  • Install raylib
  • Execute projectSetup.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

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's to be done?

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

raylib-zig's People

Contributors

not-nik avatar

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.