summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--main.c42
2 files changed, 28 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index e673e5f..2444ff5 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
desktop:
zig cc -target native main.c -o game -lGL -lm -lpthread -ldl -lrt -lX11 -Iraylib/src -Iraygui/src lib/tux/libraylib.a && ./game
web:
- emcc -Os -Wall main.c -o game -Iraylib/src -Iraygui/src lib/web/libraylib.a -o output/index.html -s USE_GLFW=3 -s FULL_ES3 -DPLATFORM_WEB --shell-file raylib/src/minshell.html -s TOTAL_MEMORY=268435456 -s ASYNCIFY --preload-file ./assets
+ emcc -Os -Wall main.c -o game -Iraylib/src -Iraygui/src lib/web/libraylib.a -o output/index.html -s USE_GLFW=3 -s FULL_ES3 -DPLATFORM_WEB --shell-file raylib/src/minshell.html -s TOTAL_MEMORY=268435456 --preload-file ./assets
diff --git a/main.c b/main.c
index 2b1677c..9d65338 100644
--- a/main.c
+++ b/main.c
@@ -8,6 +8,10 @@
#include "raylib.h"
#include <stdio.h>
+#ifdef __EMSCRIPTEN__
+#include <emscripten/emscripten.h>
+#endif
+
#define RAYGUI_IMPLEMENTATION
#include "raygui.h"
@@ -112,6 +116,24 @@ void DrawOutput();
void HandleDroppedFiles();
+void UpdateDrawFrame()
+{
+ HandleDroppedFiles();
+
+ BeginDrawing();
+ ClearBackground(RAYWHITE);
+
+ DrawElementBorders();
+ SetupDifference();
+ DrawUI();
+ ResolveMouseState();
+ DrawCodeDisplay();
+ CheckDifference();
+ DrawOutput();
+
+ EndDrawing();
+}
+
int main()
{
InitWindow(screenWidth, screenHeight, "DrawTexturePro Example");
@@ -139,24 +161,14 @@ int main()
elementRender.height - 20
);
-
+#ifdef __EMSCRIPTEN__
+ emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
+#else
while (!WindowShouldClose())
{
- HandleDroppedFiles();
-
- BeginDrawing();
- ClearBackground(RAYWHITE);
-
- DrawElementBorders();
- SetupDifference();
- DrawUI();
- ResolveMouseState();
- DrawCodeDisplay();
- CheckDifference();
- DrawOutput();
-
- EndDrawing();
+ UpdateDrawFrame();
}
+#endif
CloseWindow();
return 0;