autogen bindings to Raylib 4.0 and convenience wrappers on top. Requires use of `unsafe`

Overview

Raylib-CsLo

Status PRE-ALPHA Commit Activity .NET 6.0 Chat on Discord

Raylib-CsLo

LowLevel autogen bindings to Raylib 4.0 and convenience wrappers on top.

  • Requires use of unsafe
  • A focus on performance. No runtime allocations if at all possible.
  • because these are autogen, there won't be any intellisense docs. read the raylib cheatsheet for docs

Table of Contents

🚧 🚨 🚧 UNDER CONSTRUCTION 🚧 🚨 🚧

Currently the bindings work, but because these are bare-bones, autogen bindings, they are not user friendly, even for unsafe use. Right now only about 10 core examples have been ported.

Release timeline

PRE-ALPHA

  • The current status.
  • You can look around, try out the samples, but I would not recomend using it.

ALPHA

  • A Nuget package will be released at that time.
  • Triggered when all the core examples are ported. This will ensure that a minimal set of convenience wrappers are in place to keep things from getting too miserable.

BETA

  • Triggered when the model and shaders examples are ported.

RELEASE

  • Triggered when all examples are ported. You can contribute to make this happen.

Differences from raylib-cs

raylib-cs raylib-cslo
each binding is hand crafted with carefull design Autogen with wrappers to make the raylib examples work (with minimal changes). Bindings not used in examples will probably be painful to use (example: convert sbyte* to strings).
Optimized for normal C# usage Optimized for maximum performance and requires unsafe
New Raylib version? Harder to detect breaking changes New Raylib version? Breaking changes are easy to spot and fix
includes Intellisence docs No docs. Use the Cheatsheet
has a long track record didn't exist till mid november 2021!
has lots of examples not that many examples yet
zlib licensed lgpl licensed
Nuget Package just this repo right now
Stable in development
Works with various dotnet flavors? Focus on DotNet6.0
lots of contribs just little 'ol me

Usage Tips / FAQ

  • Is there a wrapper for this function? or do I have to really cast my Enum to int?
    • The autogen bindings are left untouched, however convenience wrappers are added. Usually these will automagically "work" via function overloads, but where this is not possible, try adding an underscore _ to the end of the function/property. For example: Camera3D.projection_ = CameraProjection.CAMERA_ORTHOGRAPHIC; or Gesture gesture = Raylib.GetGestureDetected_();
  • I ran the examples in a profiler. What are all these sbyte[] arrays being allocated?
    • A pool of sbyte[] is allocated for string marshall purposes, to avoid runtime allocations.
  • Why don't you add wrappers for the Math helpers?
    • crossing between Managed and Native code isn't free. Better you do all your maths in managed code, and pass the final result to raylib.
  • Why are my matricies corrupt?
    • Raylib/OpenGl uses column-major matricies, while dotnet/vulkan/directx uses row-major. When passing your final calculated matrix to raylib for rendering, call Matrix4x4.Transpose(yourMatrix)

How to Contribute

  1. assume you are using Visual Studio (or maybe rider?) and can run dev.sln
  2. fork the repo, build and try out the example project
  3. Look at how a lot of the raylib functions used in the core examples have convenience wrappers.
  4. Pick one of the raylib example groups not being worked on, and let novaleaf know either on discord or via an issue
  5. port the example group, following the general design as the core examples.
example group contrib doing port done?
core novaleaf [ ]
shapes [ ]
textures [ ]
text [ ]
models [ ]
shaders [ ]
audio [ ]
physics [ ]
Comments
  • Raylib 4.2 is already out, do you plan in supporting it or are u even already on the process?

    Raylib 4.2 is already out, do you plan in supporting it or are u even already on the process?

    Title :)

    4.2 is quite some major release, I really would love to encourage you keeping it continuosly up to date, its really worth this library especially having it with .net 7 now :D

    enhancement 
    opened by Shpendicus 14
  • LoadShaderFromMemory Function is not working.

    LoadShaderFromMemory Function is not working.

    Using LoadShaderFromMemory returns a shader but when used in Raylib.BeginShaderMode(shader); the shader does not work. Doing the exact same thing in a project using Raylib cs everything works as expected.

    Does the first try-statement throw an exception if "vsCode" parameter is null?

    Raylib CsLo Binding Code:

    public unsafe static Shader LoadShaderFromMemory(string? vsCode, string fsCode)
    {
        SpanOwner<sbyte> spanOwner = vsCode.MarshalUtf8();
        try
        {
            SpanOwner<sbyte> spanOwner2 = fsCode.MarshalUtf8();
            try
            {
                return LoadShaderFromMemory(spanOwner.AsPtr(), spanOwner2.AsPtr());
            }
            finally
            {
                spanOwner2.Dispose();
            }
        }
        finally
        {
            spanOwner.Dispose();
        }
    }
    

    Raylib Cs Binding Code:

    public unsafe static Shader LoadShaderFromMemory(string vsCode, string fsCode)
    {
        using UTF8Buffer uTF8Buffer = vsCode.ToUTF8Buffer();
        using UTF8Buffer uTF8Buffer2 = fsCode.ToUTF8Buffer();
        return LoadShaderFromMemory(uTF8Buffer.AsPointer(), uTF8Buffer2.AsPointer());
    }
    
    opened by SoloByte 9
  • Would it be possible to create c# bindings for rres resource packer system?

    Would it be possible to create c# bindings for rres resource packer system?

    Issue description

    Dealing with exported resources in raylib with c# is complicated right now.

    The default way is to copy the resource folder to the output directory but when distributing your game/app all resources are visible to the customer. (among many other problems with that way)

    The problem is that loading resources from anywhere else than the disk is very complicated or not possible. (to my knowledge with raylib c# bindings) So my only solution would be to compress/encrypt the resources when building and then uncompress/decrypt them when the game/app is started but then the resources are visible again to the user while the game/app is running.

    Raysan already implemented a solution for raylib called rres but it is only available for c right now. The resource packer can already be used to pack all the resources into a rres file but there is no way to load that rres file and transform it into raylib types like image, font, wave, etc. right now.

    It would be really nice if there would be separate bindings for rres so it can be used with c# and it would make raylib with c# much more robust.

    PS: At least it would be nice to know if you are interested in doing that at all. Because I donΒ΄t need it right now and if you would like to do it I am not going to look for another solution.

    I will also ask ChrisDill with raylib-cs bindings.

    Thanks!

    opened by SoloByte 7
  • Safe codegen

    Safe codegen

    W.I.P

    Using the Raylib-CsLo\sub-modules\raylib\parser\raylib_api.json i can do some code generation with c# to make the C# class

    What do you think about moving all safe code to a RaylibS class as I have found the overloads a bit messy with intellisense

    opened by IrishBruse 7
  • [v4.2] Build Raylib native binaries for OSX

    [v4.2] Build Raylib native binaries for OSX

    Raylib-CsLo bundles a custom version of the Raylib native binary: it's compiled to include extras such as raygui,physac, and easings.

    However Raylib 4.2 changes it's project structures. I was able to build the windows x64 binaries properly, but was unable to build either the linux or osx binaries.

    as building native binaries on various platforms is not my area of expertise, I ask for help here.

    In the meantime, the Raylib-CsLo 4.2 version is on Nuget as a pre-release, Win_x64 only build. The release version of CsLo's nuget package will remain 4.0 until this issue is resolved.

    If you are interested in helping

    See the https://github.com/NotNotTech/Raylib-CsLo/tree/main/sub-modules folder's readme for the current (broken) workflow for building linux.

    When I followed the linux steps (Ubuntu 22.04 x64) This is the error I received when calling make:

    Creating bin/Release.DLL Linking raylib /usr/bin/ld: obj/x64/Release.DLL/rtextures.o: relocation R_X86_64_TPOFF32 against `stbi__g_failure_reason' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: failed to set dynamic section sizes: bad value collect2: error: ld returned 1 exit status make[1]: *** [Makefile:117: bin/Release.DLL/raylib.dll] Error 1 make: *** [Makefile:36: raylib] Error 2

    It seems to be something about the .sofailing to build.

    bug good first issue help wanted 
    opened by jasonswearingen 6
  • Code style

    Code style

    • I went and added a better .editorconfig and made changed to suit the project
    • Updated the bindings to use the proper commit with submodules
    • Cleaned up alot of the code that was now giving errors.
    • All tests still pass
    opened by IrishBruse 4
  • SIGSEGV code 139 when caling DrawTextEx

    SIGSEGV code 139 when caling DrawTextEx

    Title.

    calling this code with the empty string ""here WORKS: Raylib.DrawTextEx(logText.Src, "", new Vector2(pos.X, pos.Y) * 1.2f, logText.Size, 1f, Raylib.RED);

    But this FAILS: Raylib.DrawTextEx(logText.Src, "A", new Vector2(pos.X, pos.Y) * 1.2f, logText.Size, 1f, Raylib.RED);

    Dont mind variable "LogText" its just my custom struct either way its used in both of the above and it works in one of it.

    Need Repro 
    opened by Shpendicus 3
  • Change-Request: Put all Colors in

    Change-Request: Put all Colors in "Color" struct

    Title.

    Its bit more clearer and semantically correct to say "Color.WHITE" then "Raylib.WHITE" or even when "using static Raylib"; "WHITE"

    IMHO.

    Atleast think about it, nothing big of a complain here just some small hint.

    Cheers nd thx for doing work to perma upgrade raylib man!

    wontfix 
    opened by Shpendicus 3
  • ExportWaveAsCode/ExportImageAsCode do not work as expected because they export as an .h file.

    ExportWaveAsCode/ExportImageAsCode do not work as expected because they export as an .h file.

    ExportWaveAsCode/ExportImageAsCode functions are meant to export to an .h file which is not directly usable in c# ... Is there any way to fix this with the bindings?

    opened by SoloByte 3
  • Null string conversion

    Null string conversion

    Wherever null string is accepted it is converted to a valid pointer to a '\0' instead of null. This produces a warning when using LoadShader since '\0' is not a valid file path but at least it works since raylib checks if file was loaded correctly. This completely breaks LoadShaderFromMemory however because it's trying to compile '\0' as a shader.

    opened by veins1 3
  • RayGui methods not working

    RayGui methods not working

    When I'm trying to call a RayGui method, I get this error in the console. Did I massively overlook something?

    Code

    using Raylib_CsLo;
    
    namespace PixelArtGame
    {
        internal class Program
        {
            static void Main(string[] args)
            {
                Raylib.InitWindow(800, 480, "PixelArtGame");
                RayGui.GuiLoadStyleDefault();
            }
        }
    }
    

    Error

    Unhandled exception. System.EntryPointNotFoundException: Unable to find an entry point named 'GuiLoadStyleDefault' in DLL 'raylib'.
       at Raylib_CsLo.RayGui.GuiLoadStyleDefault()
       at CircleClicker.Program.Main(String[] args) in .\PixelArtGame\Program.cs:line 16
    
    .\PixelArtGame\bin\Debug\net6.0\PixelArtGame.exe (process 12292) exited with code -532462766.
    
    opened by ZackaryH8 3
  • LoadShader  illegal non-ASCII character

    LoadShader illegal non-ASCII character

    Hallo, i wanted to load a Shader.

    So I first tried using LoadShader.. LoadShader(Textformat(string, value),Textformat(string,value))

    It then showes: [11:41:07 INF] FILEIO: [Data/Scenes/Test2/Shader/base_lighting.vert] Text file loaded successfully [11:41:07 INF] FILEIO: [Data/Scenes/Test2/Shader/lighting.frag] Text file loaded successfully

    but then it print out this: ` [11:41:07 WRN] SHADER: [ID 4] Failed to compile vertex shader code [11:41:07 WRN] SHADER: [ID 4] Compile error: ERROR: 0:1: '' : illegal non-ASCII character (0xef) ERROR: 0:1: '' : illegal non-ASCII character (0xbb) ERROR: 0:1: '' : illegal non-ASCII character (0xbf)

    [11:41:07 WRN] SHADER: [ID 5] Failed to compile fragment shader code [11:41:07 WRN] SHADER: [ID 5] Compile error: ERROR: 0:1: '' : illegal non-ASCII character (0xef) ERROR: 0:1: '' : illegal non-ASCII character (0xbb) ERROR: 0:1: '' : illegal non-ASCII character (0xbf)

    [11:41:07 WRN] SHADER: [ID 6] Failed to link shader program [11:41:07 WRN] SHADER: [ID 6] Link error: Attached vertex shader is not compiled. `

    My shader Files are from the basic_lighting Example.

    opened by eliasstepanikVW 1
  • SetWindowPosition overrides WindowSize

    SetWindowPosition overrides WindowSize

    Have to follow SetWindowPosition with SetWindowSize

    InitWindow(0, 0, "test");
    SetWindowPosition(x, y);
    SetWindowSize(wid, hgt);
    

    or else the size will revert to some default.

    opened by bradmartin333 0
  • Want to maintain this project?

    Want to maintain this project?

    If you use/love raylib-cslo and are interested in helping to maintain the binding, let me know. Raylib-cslo is up to date and working 100%. I just don't really use it anymore so planning ahead, now (when no fires to put out) would be a good opportunity for a new maintainer to step in. It's super easy to update the bindings on new raylib releases. The biggest problems raylib-cslo faces is building native binaries on various platforms when a new version is deployed.. Check the issues for more detail.

    No rush to do this, just want to plan ahead.

    help wanted 
    opened by jasonswearingen 3
  • [Native Regression, Tracking] Bug in Streaming Audio subsystem

    [Native Regression, Tracking] Bug in Streaming Audio subsystem

    Discovered issue in raylib 4.2 audio subsystem, seems to regard streaming audio.

    https://github.com/raysan5/raylib/issues/2714

    this issue will track progress on native fix.

    This bug was found by running through the examples, which CsLo uses as verification tests. The streaming audio examples cause the next following screen to crash.

    bug Upstream 
    opened by jasonswearingen 0
  • Add auto-build via Github actions

    Add auto-build via Github actions

    It would be nice to have an automated build process like what raylib-cs has. This would automatically build the windows,linux,osx binaries when a code change is commited.

    Currently building for Windows and Linux can be done manually, which is good enough for me in the medium term, which is why I can't prioritize working on it myself for now.

    Update: it seems raylib-cs doesn't actually build, it just coppies the native raylib binaries. So an actual github action to build+bundle extras seems like it would be a lot more work!

    enhancement good first issue help wanted 
    opened by jasonswearingen 0
Owner
NotNot
NotNot
A top-down shooter made for the raylib 5K gamejam.

ANTISPELL Description A top-down shooter where you have to use your enemies' attacks to spell your spells! Features Absorb letters getting close to en

Francisco Javier AndrΓ©s Casas Barrientos 3 Apr 9, 2022
SWIG bindings for raylib (to Lua, and hopefully other languages)

swigraylib SWIG binding for raylib This repo generates raylib bindings to other languages (eg. Lua), by providing a raylib.i SWIG interface file. SWIG

null 6 Oct 28, 2021
RayLib extern bindings for Haxe

raylib-haxe Haxe bindings for RayLib usage haxelib git raylib-haxe https://github.com/haxeui/raylib-haxe package; import RayLib.*; import RayLib.Cam

HaxeUI 24 Dec 3, 2022
A powerful C++ timer, requires C++14 or later standard.

Timer A powerful C++ timer, requires C++14 or later standard. Concepts Not invade the target program API I want to design a timer that does not "invad

null 2 Nov 30, 2021
Utilities and common code for use with raylib

Utilities and shared components for use with raylib

Jeffery Myers 86 Dec 1, 2022
Integrate PhysFS with raylib, allowing to load images, audio and fonts from data archives.

raylib-physfs Integrate the virtual file system PhysicsFS with raylib, allowing to load images, audio, and fonts from data archives. Features Load the

Rob Loach 21 Dec 3, 2022
My collection of raylib code examples - For learning the C language with 2D and 3D games.

Raylib-Examples My collection of raylib examples. ( https://www.raylib.com/index.html ) For Raylib Version of 4 april 2020 ( Notepad++ windows install

Rudy Boudewijn van Etten 49 Dec 28, 2022
The Ultimate Raylib gaming library wrapper for Nim

NimraylibNow! - The Ultimate Raylib wrapper for Nim The most idiomatic and up-to-date wrapper for Raylib gaming C library. Use this library if you wan

Dmitry Matveyev 138 Dec 22, 2022
Load Aseprite files for animated sprites in raylib.

raylib-aseprite Load Aseprite .aseprite files for animated sprites in raylib. Features Load Aseprite files directly for use in raylib Draw individual

Rob Loach 30 Dec 20, 2022
A pong clone written in C++ with Raylib

How To Play Objective: first player to reach 10 points is the winner! PLAYER 1: W: up S: down PLAYER 2: ARROW UP or I: up ARROW DOWN or S: down Requir

Victor Sarkisov 1 Nov 8, 2021
Pong clone made in C++ with raylib

Raypong Pong clone made in C++ with raylib. Dependencies ...C++ and raylib lol Building To build, use these commands: mkdir build # Create a build dir

Mars 0 Feb 4, 2022
raylib Nuget package

raylib Nuget package This is a Nuget package for the popular raylib video game programming library. Resources used to create this package are as follo

Samuel Gomes 6 Dec 5, 2022
Minimalistic assertion library for raylib.

raylib-assert Minimalistic assertion library for raylib. Example #include "raylib.h" #include "raylib-assert.h" int main(void) { Assert(10 == 10)

Rob Loach 2 Jan 12, 2022
A Rogue like library on top of libtcod

Pataro A C++ 17 Rogue Like library built on top of lib TCOD. Pataro means Walker Male in Quenya. Read ARCHITECTURE.md before diving in.

Alexandre Plateau 24 Dec 1, 2022
Unofficial C++ beta SDK for the top.gg API.

topgg-cpp-sdk (Beta) Unofficial C++11 beta SDK for the top.gg API. Please note that the library is currently not completed yet! Requirements: libcurl

7 Nov 16, 2021
Python bindings for Wasm3, the fastest WebAssembly interpreter

pywasm3 Python bindings for Wasm3, the fastest WebAssembly interpreter Main repository: Wasm3 project Install # Latest release: pip3 install pywasm3

Wasm3 Labs 49 Dec 27, 2022
A tool for use with clang to analyze #includes in C and C++ source files

Include What You Use For more in-depth documentation, see docs. Instructions for Users "Include what you use" means this: for every symbol (type, func

null 3.2k Jan 4, 2023
A simple and easy-to-use library to enjoy videogames programming

hb-raylib v3.5 Harbour bindings for raylib 3.5, a simple and easy to use library to learn videogames programming raylib v3.5. The project has an educa

MarcosLMG 1 Aug 28, 2022
RapidObj is an easy-to-use, single-header C++17 library that loads and parses Wavefront .obj files.

RapidObj About Integration Prerequisites Manual Integration CMake Integration API RapidObj Result Next Steps OS Support Third Party Tools and Resource

Slobodan Pavlic 108 Jan 2, 2023