stanoddly / DotnetRaylibWasm

Prototype for .NET 7 with Raylib compiled into WebAssembly (wasm)
MIT License
61 stars 8 forks source link

DotnetRaylibWasm

GitHub Pages Demo

This is a fully working prototype for .NET 7 with Raylib ahead-of-time 🚀 compiled into WebAssembly (wasm). See a couple of known issues for limitations.

Local setup

Make sure you have the latest version of .NET 7 for example from here, the prototype was built with:

dotnet --version
7.0.100

Install the official wasm tooling:

dotnet workload install wasm-tools
dotnet workload install wasm-experimental

Install a tool to create ad-hoc http server to server application/wasm:

dotnet tool install --global dotnet-serve

libraylib.a included in the repository is pre-compiled from my machine, but GitHub Pages workflow compiles Raylib form PLATFORM=WEB on its own every build.

Overview

Examples are copied from ChrisDill/Raylib-cs-Examples. Few examples were removed since they used functionality removed from Raylib 4.2. This project uses 4.2.0.2 of the Raylib-cs nuget package.

./Examples

The project which makes the WebAssembly possible is here:

./DotnetRaylibWasm

Run it

Note The latest version of main branch is available here. To run it locally follow these instructions.

publish the solution from the root of the repository. Don't even try to use just build, it's buggy. Note the publishing takes a while:

dotnet publish -C Release

To serve the files use this command from the root (change \ to / in file path if you are not on Windows):

dotnet serve --mime .wasm=application/wasm --mime .js=text/javascript --mime .json=application/json --directory DotnetRaylibWasm\bin\Debug\net7.0\browser-wasm\AppBundle\

Copy the link from the output and open it in your browser (tested on the latest Chrome).

References

Plenty of information isn't really public or well documented, so this section collects found information: