.NET/C# bindings for r3d, an advanced 3D rendering library built on top of raylib.
Experimental: This package is in early development. APIs may change between versions.
Note: r3d itself is under heavy development and has not reached version 1.0. Expect breaking changes in the underlying library as well.
Important: For now this package includes its own
raylib.dllfrom r3d with some features enabled (like HDR file loading). This will overwrite the native library provided by raylib-cs.
dotnet add package R3D-cs --prerelease
- Clone the repo with submodules:
git clone --recursive https://github.com/graphnode/r3d-cs.git - Add the
R3D-csproject to your solution as an existing project. - Build the native libraries from the
External/r3dsubmodule (see Building) and copy them toR3D-cs/runtimes/<rid>/native/.
- .NET 10.0 or later (might work with earlier versions but not tested)
- Raylib-cs (included as a dependency)
- Native r3d library for your platform (included in package)
usingSystem.Numerics;usingRaylib_cs;usingR3D_cs;// Initialize windowRaylib.InitWindow(800,450,"[r3d] - Basic example");Raylib.SetTargetFPS(60);// Initialize R3DR3D.Init(Raylib.GetScreenWidth(),Raylib.GetScreenHeight());// Create meshesvarplane=R3D.GenMeshPlane(1000,1000,1,1);varsphere=R3D.GenMeshSphere(0.5f,64,64);varmaterial=R3D.GetDefaultMaterial();// Setup environmentvarenv=R3D.GetEnvironmentEx();env.Ambient.Color=newColor(10,10,10,255);R3D.SetEnvironmentEx(env);// Create lightLightlight=R3D.CreateLight(LightType.Spot);R3D.LightLookAt(light,newVector3(0,10,5),Vector3.Zero);R3D.EnableShadow(light);R3D.SetLightActive(light,true);// Setup cameravarcamera=newCamera3D(){Position=newVector3(0,2,2),Target=Vector3.Zero,Up=newVector3(0,1,0),FovY=60};// Main loopwhile(!Raylib.WindowShouldClose()){Raylib.UpdateCamera(refcamera,CameraMode.Orbital);Raylib.BeginDrawing();Raylib.ClearBackground(Color.RayWhite);R3D.Begin(camera);R3D.DrawMesh(plane,material,newVector3(0,-0.5f,0),1.0f);R3D.DrawMesh(sphere,material,Vector3.Zero,1.0f);R3D.End();Raylib.EndDrawing();}// CleanupR3D.UnloadMesh(sphere);R3D.UnloadMesh(plane);R3D.Close();Raylib.CloseWindow();- R3d.Net - .NET bindings for r3d by Kiriller12
dotnet build R3D-cs.slnThe r3d source is included as a git submodule at External/r3d. To update to a newer version:
cd External/r3d
git fetch origin
git checkout <new-tag-or-commit># e.g. git checkout v0.9cd ../..
git add External/r3dAfter updating, regenerate the bindings and rebuild the native libraries:
# Regenerate C# bindingscd R3D-cs.GenerateBindings
dotnet run
# Build native libraries for local testingcd ../External/r3d
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON \
-DR3D_ASSIMP_VENDORED=ON -DR3D_RAYLIB_VENDORED=ON
cmake --build build --config ReleaseFeel free to open an issue. If you'd like to contribute, please fork the repository and make changes as you'd like. Pull requests are welcome.
This project is licensed under the zlib license. See r3d for the original library license.
We're grateful to the raylib, r3d, raylib-cs, and r3d-net developers for their outstanding contributions to the raylib community. This project's structure, documentation, and packaging are all inspired by their excellent work.
