Raylib-CsLo 4.0.0-beta.0

This is a prerelease version of Raylib-CsLo.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Raylib-CsLo --version 4.0.0-beta.0                
NuGet\Install-Package Raylib-CsLo -Version 4.0.0-beta.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Raylib-CsLo" Version="4.0.0-beta.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Raylib-CsLo --version 4.0.0-beta.0                
#r "nuget: Raylib-CsLo, 4.0.0-beta.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Raylib-CsLo as a Cake Addin
#addin nuget:?package=Raylib-CsLo&version=4.0.0-beta.0&prerelease

// Install Raylib-CsLo as a Cake Tool
#tool nuget:?package=Raylib-CsLo&version=4.0.0-beta.0&prerelease                

<h1 align="center"> <a href="#"><img align="center" src="meta/logos/raylib-cslo_128x128.png" height="96"> Raylib-CsLo</a> <br /> </h1>

<div align="center">

Status BETA Nuget Package Commit Activity .NET 6.0 Chat on Discord

</div>

Raylib-CsLo

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

  • Requires use of unsafe
  • Requires use of DotNet 6.0
  • 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 🚧🚨🚧

The entire API of Raylib 4.0 is available via these bindings. However, as the bindings are auto-generated, they are not user friendly, even for unsafe use.

To make these bindings "friendly" to C# use, convenience wrappers are being added, so you can use these bindings with a minimal amount of unsafe code.

The current mission of this project is to port all Raylib examples (more than 120 of them) to work with these bindings, with as little modification to the example code as possible. In doing so, convenience wrappers will be added for the Raylib api's used in the examples. This is a good heuristic for "primary usage scenarios", so writing wrappers for these API's should make these bindings user friendly in the fastest time, while also providing valuable C# examples.

Right now the Core, Model, and Shader examples have been fully ported.

Release timeline

BETA

  • The current status.
  • Triggered when the model and shaders examples are ported.
  • A Nuget package is avalable
  • Core, Model, and Shader examples are ported.

RELEASE

  • Triggered when all remaining 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 only the Core examples
zlib licensed lgpl licensed
Nuget Package Nuget Package
Stable Alpha
Works with various dotnet flavors? Focus on DotNet6.0
lots of contribs just little 'ol me

Usage Tips / FAQ

  • Does Raylib-CsLo include the SOME_FUNCTION_YOU_NEED() function?
    • Raylib-CsLo has bindings for everything in the Raylib 4.0 release, with the exception of:
      • Native Memory allocation functions: use System.Runtime.InteropServices.NativeMemory.Alloc() instead
      • LogCustom() is ported but doesn't support variable length arguments.
  • Why didn't you add a wrapper for function SOME_OTHER_FUNCTION_YOU_NEED()?
    • Raylib-CsLo uses a manual marshalling technique, as the built in PInvoke marshalling is not very efficienct. Unfortunately writing wrappers takes time.
    • I am going through all the examples and porting them, and when I do I'm adding wrappers to the raylib api's used (I'm using examples as a heuristic for "commonly used api's) For a function I haven't written a wrapper for, you can look at how I do it and write your own wrapper, or can help the project by submitting a PR.
    • On average it only takes me about 15 min to port each example, but there are many examples.
  • How do I convert a string to sbyte* or vice-versa?
    • Look if there is a wrapper overload you can call. If not, you can write your own wrapper by coppying the pattern in one of the existing wrappers.
  • 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?
    • The RayMath helper functions have been translated into C# code. This is because 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 ~ ~ who is doing port ~ ~ done? ~
core novaleaf [X]
shapes [ ]
textures [ ]
text [ ]
models novaleaf [X]
shaders novaleaf [X]
audio [ ]
physics [ ]

ChangeLog

  • 4.0.0-beta.0 (2021/11/20): Model, and Shader examples ported.
  • 4.0.0-alpha.2 (2021/11/18): Model examples ported. AutoGen Bindings expanded to include all api's exposed by Raylib.dll (adding RayMath, RlGl, RayGui)
  • 4.0.0-alpha.1 (2021/11/16): all Core examples ported, so "feature complete" for the workflows used in those examples (and, complete only for those workflows)
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Raylib-CsLo:

Package Downloads
RayWrapper.Base

This is the Base package for RayWrapper

Raylib_ImGui

Open-source ImGui renderer for Raylib

RayWork.RLImgui

Imgui.Net integration

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Raylib-CsLo:

Repository Stars
sinshu/meltysynth
A SoundFont MIDI synthesizer for .NET
Version Downloads Last updated
4.2.0.9 10,573 3/2/2023
4.2.0.9-pre-m1-0 5,948 3/1/2023
4.2.0.8 6,082 3/1/2023
4.2.0.7 5,994 2/28/2023
4.2.0.6 6,098 2/25/2023
4.2.0.5 6,241 2/6/2023
4.2.0.5-alpha1 5,842 2/2/2023
4.2.0.4 6,143 1/31/2023
4.2.0.3 8,930 9/22/2022
4.2.0.2 5,755 9/20/2022
4.2.0.1 5,850 9/20/2022
4.2.0-alpha1 5,686 9/20/2022
4.2.0-alpha0 5,519 9/19/2022
4.0.1 8,677 4/9/2022
4.0.0 6,796 1/16/2022
4.0.0-rc.5.0 331 12/15/2021
4.0.0-rc.4.2 173 12/11/2021
4.0.0-rc.4.1 169 12/9/2021
4.0.0-rc.4.0 182 12/5/2021
4.0.0-rc.3.1 943 11/29/2021
4.0.0-rc.3 848 11/29/2021
4.0.0-rc.2 182 11/27/2021
4.0.0-rc.1 2,986 11/25/2021
4.0.0-rc.0.1 5,783 11/23/2021
4.0.0-rc.0 146 11/23/2021
4.0.0-beta.2 157 11/22/2021
4.0.0-beta.1 936 11/20/2021
4.0.0-beta.0 946 11/20/2021
4.0.0-alpha.2 154 11/19/2021
4.0.0-alpha.1 219 11/17/2021
4.0.0-alpha.0 248 11/17/2021

Beta release.  Review the examples on github.