Skip to content

Commit

Permalink
WIP WASM test
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Slusny <[email protected]>
  • Loading branch information
Tomas Slusny committed Oct 23, 2024
1 parent b5c60ef commit 89e4bc7
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 12 deletions.
35 changes: 23 additions & 12 deletions src/Raylib.NET.Test/Raylib.NET.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
<?xml version="1.0"?>
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<ProjectReference Include="..\Raylib.NET\Raylib.NET.csproj" />
</ItemGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Raylib.NET.Native\Raylib.NET.Native.csproj"/>
<ProjectReference Include="..\Raylib.NET\Raylib.NET.csproj"/>
</ItemGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<WasmMainJSPath>main.js</WasmMainJSPath>
<InvariantGlobalization>true</InvariantGlobalization>
<WasmEmitSymbolMap>false</WasmEmitSymbolMap>
<RunAOTCompilation>true</RunAOTCompilation>
<WasmBuildNative>true</WasmBuildNative>
</PropertyGroup>
<ItemGroup>
<DirectPInvoke Include="raylib"/>
<NativeLibrary Include="$(OutputPath)libraylib.a"/>
</ItemGroup>
</Project>
23 changes: 23 additions & 0 deletions src/Raylib.NET.Test/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Raylib.NET</title>
<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" />

<style>
canvas.emscripten {
width: 100%;
height: 100%;
}
</style>
</head>

<body>
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
<script type="module" src="./main.js"></script>
</body>

</html>
10 changes: 10 additions & 0 deletions src/Raylib.NET.Test/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { dotnet } from './dotnet.js'

await dotnet
.withDebugging(1)
.withDiagnosticTracing(false)
.withApplicationArgumentsFromQuery()
.create();

dotnet.instance.Module['canvas'] = document.getElementById('canvas');
await dotnet.run();

0 comments on commit 89e4bc7

Please sign in to comment.