Skip to content
This repository was archived by the owner on Jul 13, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
with:
path: DotnetRaylibWasmRepo

- name: Setup .NET7
- name: Setup .NET8
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.100'
dotnet-version: '8.0.200'

- name: Install wasm-tools
run: |
Expand All @@ -27,7 +27,8 @@ jobs:
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v11
with:
version: 3.1.12
# https://github.com/dotnet/runtime/blob/v8.0.2/src/mono/wasm/emscripten-version.txt
version: 3.1.34
actions-cache-folder: 'emsdk-cache'

- name: Build raylib for Web
Expand All @@ -49,4 +50,4 @@ jobs:
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: DotnetRaylibWasmRepo/DotnetRaylibWasm/bin/Release/net7.0/browser-wasm/AppBundle
publish_dir: DotnetRaylibWasmRepo/DotnetRaylibWasm/bin/Release/net8.0/browser-wasm/AppBundle
7 changes: 4 additions & 3 deletions DotnetRaylibWasm/DotnetRaylibWasm.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
<WasmMainJSPath>main.js</WasmMainJSPath>
<OutputType>Exe</OutputType>
Expand All @@ -14,18 +14,19 @@
<TrimMode>full</TrimMode>
<!-- This is to basically disable globalization to exclude icudt.dat (1.5MB) and reduce size of dotnet.wasm -->
<InvariantGlobalization>true</InvariantGlobalization>
<LangVersion>12</LangVersion>
</PropertyGroup>

<Choose>
<When Condition=" $(Configuration) == 'Debug' ">
<PropertyGroup>
<WasmEmitSymbolMap>true</WasmEmitSymbolMap>
<EmccFlags>-sUSE_GLFW=3 -sASYNCIFY=1 -sVERBOSE=1 -Wbad-function-cast -Wcast-function-type -O2 -g3 -sVERBOSE=1 -sINITIAL_MEMORY=128MB -sMAXIMUM_MEMORY=2048MB -sALLOW_MEMORY_GROWTH=1 -sASYNCIFY_STACK_SIZE=10000000</EmccFlags>
<EmccFlags>-sUSE_GLFW=3 -sVERBOSE=1 -Wbad-function-cast -Wcast-function-type -O2 -g3 -sVERBOSE=1 -sINITIAL_MEMORY=128MB -sMAXIMUM_MEMORY=2048MB -sALLOW_MEMORY_GROWTH=1 -sASYNCIFY_STACK_SIZE=10000000</EmccFlags>
</PropertyGroup>
</When>
<When Condition=" $(Configuration) == 'Release' ">
<PropertyGroup>
<EmccFlags>-s USE_GLFW=3 -sASYNCIFY=1 -O3</EmccFlags>
<EmccFlags>-s USE_GLFW=3 -O3</EmccFlags>
</PropertyGroup>
</When>
</Choose>
Expand Down
2 changes: 1 addition & 1 deletion DotnetRaylibWasm/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<h1>Dotnet + Raylib + Wasm prototype</h1>
<div>
<p>⚠️The very first example you open will download around 30MB of resources for ALL examples, so it might take a while. The rest of the examples will load almost immediatelly.</p>
<p>Please report any errors <a href="https://github.com/disketteman/DotnetRaylibWasm/issues">here</a>. You can find logs in the <a href="https://developer.chrome.com/docs/devtools/console/">Console</a>.</p>
<p>Please report any errors <a href="https://github.com/stanoddly/DotnetRaylibWasm/issues">here</a>. You can find logs in the <a href="https://developer.chrome.com/docs/devtools/console/">Console</a>.</p>
</div>
<hr />
<ul>
Expand Down
2 changes: 1 addition & 1 deletion DotnetRaylibWasm/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
import { dotnet } from './dotnet.js'
import { dotnet } from './_framework/dotnet.js'

await dotnet
.withDebugging(1)
Expand Down
2 changes: 1 addition & 1 deletion DotnetRaylibWasm/raylib.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="modulepreload" href="./main.js" />
<link rel="modulepreload" href="./dotnet.js" />
<link rel="modulepreload" href="./_framework/dotnet.js" />

<style>
div#canvas_wrapper {
Expand Down
4 changes: 2 additions & 2 deletions Examples/Examples.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<RunWorkingDirectory>$(MSBuildThisFileDirectory)</RunWorkingDirectory>
<LangVersion>11</LangVersion>
<LangVersion>12</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

<img src="https://raw.githubusercontent.com/disketteman/DotnetRaylibWasm/main/demo.jpg" width="417" height="272">

[GitHub Pages Demo](https://disketteman.github.io/DotnetRaylibWasm/)
[GitHub Pages Demo](https://stanoddly.github.io/DotnetRaylibWasm/)

This is a fully working prototype for .NET 7 with Raylib ahead-of-time 🚀 compiled into WebAssembly (wasm). See a couple of [known issues](https://github.com/disketteman/DotnetRaylibWasm/issues) for limitations.
This is a fully working prototype for .NET 8 with Raylib ahead-of-time 🚀 compiled into WebAssembly (wasm). See a couple of [known issues](https://github.com/disketteman/DotnetRaylibWasm/issues) for limitations.

## Local setup

Make sure you have the latest version of .NET 7 for example from [here](https://dotnet.microsoft.com/en-us/download/dotnet/7.0), the prototype was built with:
Make sure you have the latest version of .NET 8 for example from [here](https://dotnet.microsoft.com/en-us/download/dotnet/8.0), the prototype was built with:
```
dotnet --version
7.0.100
8.0.200
```

Install the official wasm tooling:
Expand Down Expand Up @@ -50,13 +50,13 @@ The project which makes the WebAssembly possible is here:
`publish` the solution from the root of the repository. Don't even try to use just `build`, [it's buggy](https://github.com/disketteman/DotnetRaylibWasm/issues/7#issuecomment-1356442508). Note the publishing takes a while:

```
dotnet publish -C Release
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\
dotnet serve --mime .wasm=application/wasm --mime .js=text/javascript --mime .json=application/json --directory DotnetRaylibWasm\bin\Debug\net8.0\browser-wasm\AppBundle\
```

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