Skip to content

Commit

Permalink
Wasm works yay, but raygui is breaking something still
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 24, 2024
1 parent f48eecb commit b4cea1d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 40 deletions.
20 changes: 1 addition & 19 deletions src/Raylib.NET.Test/Program.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,17 @@
using RaylibNET;
using static RaylibNET.Raygui;
using static RaylibNET.Raylib;

bool showMessageBox = false;

InitWindow(640, 480, "Raylib.NET - Test");
SetConfigFlags((int)ConfigFlags.FLAG_WINDOW_RESIZABLE | (int)ConfigFlags.FLAG_WINDOW_HIGHDPI);
SetTargetFPS(60);

while (!WindowShouldClose())
{
BeginDrawing();

ClearBackground(GetColor((uint)GuiGetStyle((int)GuiControl.DEFAULT, (int)GuiDefaultProperty.BACKGROUND_COLOR)));
ClearBackground(Color.RAYWHITE);

DrawText("Congrats! You created your first window!", 10, 10, 20, Color.LIGHTGRAY);

if (GuiButton(new(40, 40, 120, 30), "#191#Show Message") == 1)
{
showMessageBox = true;
}

if (showMessageBox)
{
int result = GuiMessageBox(new(85, 70, 250, 100), "#191#Message Box", "Hi! This is a message!", "Nice;Cool");
if (result >= 0)
{
showMessageBox = false;
}
}

EndDrawing();
}

Expand Down
25 changes: 7 additions & 18 deletions src/Raylib.NET.Test/Raylib.NET.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,20 @@
</PropertyGroup>
<PropertyGroup>
<WasmMainJSPath>main.js</WasmMainJSPath>
<WasmEnableExceptionHandling>false</WasmEnableExceptionHandling>
<!-- <RunAOTCompilation>true</RunAOTCompilation> crashes for some reason -->
<InvariantGlobalization>true</InvariantGlobalization>
<WasmBuildNative>true</WasmBuildNative>
<InvariantGlobalization>true</InvariantGlobalization>
<!-- <RunAOTCompilation>true</RunAOTCompilation> -->
<!-- <WasmNativeStrip>true</WasmNativeStrip> -->
<!-- <EnableAggressiveTrimming>true</EnableAggressiveTrimming> -->
<!-- <PublishTrimmed>true</PublishTrimmed> -->
<!-- <TrimMode>full</TrimMode> -->
<WasmEnableExceptionHandling>false</WasmEnableExceptionHandling>
<EmccFlags>-s USE_GLFW=3 -sASYNCIFY=1 -O3</EmccFlags>
</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>
</PropertyGroup>
</When>
<When Condition=" $(Configuration) == 'Release' ">
<PropertyGroup>
<EmccFlags>-s USE_GLFW=3 -sASYNCIFY=1 -O3</EmccFlags>
</PropertyGroup>
</When>
</Choose>
<ItemGroup>
<!-- <DirectPInvoke Include="raylib"/> -->
<NativeLibrary Include="$(OutputPath)libraylib.a"/>
<!-- <NativeFileReference Include="$(OutputPath)libraylib.a"/> -->
<!-- Fix this so i dont have to copy/paste -->
<NativeFileReference Include="raylib.a"/>
<WasmExtraFilesToDeploy Include="index.html"/>
<WasmExtraFilesToDeploy Include="main.js"/>
</ItemGroup>
Expand Down
14 changes: 12 additions & 2 deletions src/Raylib.NET.Test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@
<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 {
border: 1px solid black;
width: 640px;
height: 480px;
padding: 0;
margin-left: auto;
margin-right: auto;
}
canvas.emscripten {
width: 100%;
height: 100%;
Expand All @@ -16,7 +24,9 @@
</head>

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

Expand Down
2 changes: 1 addition & 1 deletion src/Raylib.NET.Test/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dotnet } from './dotnet.js'
import { dotnet } from './_framework/dotnet.js'

await dotnet
.withDebugging(1)
Expand Down

0 comments on commit b4cea1d

Please sign in to comment.