Raylib-CsLo 4.0.0-rc.0.1

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-rc.0.1
NuGet\Install-Package Raylib-CsLo -Version 4.0.0-rc.0.1
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-rc.0.1" />
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-rc.0.1
#r "nuget: Raylib-CsLo, 4.0.0-rc.0.1"
#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-rc.0.1&prerelease

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

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

Table of Contents

About

Precise, minimal bindings to Raylib v4 and Raylib v4 Extras. Convenience wrappers are added to make it easy to work with.

How to use/install

via Nuget

  1. add the latest version of The Raylib-CsLo Nuget Package to your project
  2. Create an example project using it, the following code is coppied from The StandAlone Example's Program.cs
using Raylib_CsLo;

namespace StandaloneExample
{
	public static class Program
	{
		public static async Task Main(string[] args)
		{
			Raylib.InitWindow(1280, 720, "Hello, Raylib-CsLo");
			Raylib.SetTargetFPS(60);
			// Main game loop
			while (!Raylib.WindowShouldClose()) // Detect window close button or ESC key
			{
				Raylib.BeginDrawing();
				Raylib.ClearBackground(Raylib.SKYBLUE);
				Raylib.DrawFPS(10, 10);
				Raylib.DrawText("Raylib is easy!!!", 640 , 360, 50, Raylib.RED);
				Raylib.EndDrawing();
			}
			Raylib.CloseWindow();
		}
	}
}

via sources

  1. clone/download the github repository
  2. open ./Raylib-CsLo-DEV.sln in Visual Studio 2022.
  3. build and run.
    • the Raylib-CsLo.Examples project will run by default, and will run through all 100+ examples.
  4. For a stand-alone example, see the ./StandaloneExample folder

Release timeline

RELEASE CANDIDATE

  • The current status.
  • All Raylib features, including Extras bindings
    • raylib : Core features, including Audio.
    • rlgl : OpenGl abstraction
    • raygui : A Imperitive Gui
    • physac : A 2d physics framework
    • easings : for simple animations (Managed Port)
    • raymath : game math library (Managed Port)
  • All raylib examples are ported and working (see the github repository for the example project)
  • A Nuget package is avalable

RELEASE

  • Triggered a few weeks after the last RC issue is fixed. If you find any bugs with the release candidate, be sure to raise an issue!

Examples

Here are links to most the examples. The images/links probably won't work from Nuget. Visit the Github Repo to see it properly.

Core Shapes Textures Text Models Shaders Audio Physics
Ex1 Ex1 Ex1 Ex1 Ex1 Ex1 Ex1 Ex1
Ex2 Ex2 Ex2 alternate text is missing from this package README image Ex2 Ex2 alternate text is missing from this package README image alternate text is missing from this package README image

Differences from Raylib-Cs

Raylib-Cs Raylib-CsLo
Each binding is hand crafted with carefull design Exact Bindings (Autogen) with wrappers to make C# usage nice.
Bindings for Raylib and extras RayMath, RlGl. Bindings for Raylib and all extras (RayGui, Easings, Physac, RlGl, RayMath)
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 / Examples
has a long track record didn't exist till mid november 2021!
Lots of examples ALL Raylib examples
zlib licensed lgpl licensed
Nuget Package Nuget Package
raylib 3.7.1 Stable Raylib 4.0.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, including extras like raygui and physac, but with the exception of things in the Known Issues section further below.
  • 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)

Known Issues:

  • RayGui: be sure to call RayGui.GuiLoadStyleDefault(); right after you InitWindow(). This is needed to initialize the gui properly. If you don't, if you close a raylib window and then open a new one (inside the same app), the gui will be broken.
  • The Text.Unicode example doesn't render unicode properly. Maybe the required font is missing, maybe there is a bug in the example (Utf16 to Utf8 conversion) or maybe there is a bug in Raylib. A hunch: I think it's probably due to the fonts not including unicode characters, but I didn't investigate further.
  • Native Memory allocation functions: use System.Runtime.InteropServices.NativeMemory.Alloc() instead
  • LogCustom() is ported but doesn't support variable length arguments.

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. ??? improve the wrappers? All features are done and working 😎
~ example group ~ ~ who is doing port ~ ~ done? ~
core novaleaf [X]
shapes novaleaf [X]
textures novaleaf [X]
text novaleaf [X]
models novaleaf [X]
shaders novaleaf [X]
audio novaleaf [X]
physics novaleaf [X]

ChangeLog

  • 4.0.0-rc.0.1 (2021/11/23): Pretty things up.
  • 4.0.0-rc.0 (2021/11/22): physac.dll and bindings for it added. Physics and Audio examples ported. All raylib examples complete!
  • 4.0.0-beta.2 (2021/11/22): RayGui, and Easings Raylib.extras ported to managed code. Shapes,Textures, and Text examples ported.
  • 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)
  • 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 8,300 3/2/2023
4.2.0.9-pre-m1-0 5,571 3/1/2023
4.2.0.8 5,666 3/1/2023
4.2.0.7 5,620 2/28/2023
4.2.0.6 5,688 2/25/2023
4.2.0.5 5,773 2/6/2023
4.2.0.5-alpha1 5,492 2/2/2023
4.2.0.4 5,705 1/31/2023
4.2.0.3 8,353 9/22/2022
4.2.0.2 5,387 9/20/2022
4.2.0.1 5,460 9/20/2022
4.2.0-alpha1 5,334 9/20/2022
4.2.0-alpha0 5,157 9/19/2022
4.0.1 8,191 4/9/2022
4.0.0 6,355 1/16/2022
4.0.0-rc.5.0 303 12/15/2021
4.0.0-rc.4.2 162 12/11/2021
4.0.0-rc.4.1 162 12/9/2021
4.0.0-rc.4.0 173 12/5/2021
4.0.0-rc.3.1 929 11/29/2021
4.0.0-rc.3 833 11/29/2021
4.0.0-rc.2 165 11/27/2021
4.0.0-rc.1 2,977 11/25/2021
4.0.0-rc.0.1 5,768 11/23/2021
4.0.0-rc.0 138 11/23/2021
4.0.0-beta.2 148 11/22/2021
4.0.0-beta.1 929 11/20/2021
4.0.0-beta.0 931 11/20/2021
4.0.0-alpha.2 145 11/19/2021
4.0.0-alpha.1 205 11/17/2021
4.0.0-alpha.0 237 11/17/2021

Release Candidate.  Review the examples on github.