Add flecs

This commit is contained in:
Clément Pons 2025-03-25 17:18:06 +01:00
parent 6692bcf7ad
commit 5f74472055
5 changed files with 24 additions and 6 deletions

View File

@ -20,7 +20,8 @@
"name": "Emscripten",
"includePath": [
"${workspaceFolder}/../sokol",
"${workspaceFolder}/../sokol_gp"
"${workspaceFolder}/../sokol_gp",
"${workspaceFolder}/../flecs/distr"
],
"defines": [
"_DEBUG",
@ -32,7 +33,6 @@
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-clang-x64",
"compilerPathInCppPropertiesJson": "C:\\Users\\c.pons\\Documents\\Perso\\Git\\emsdk\\upstream\\bin\\clang.exe",
"mergeConfigurations": false,
"browse": {
"path": [
@ -47,7 +47,12 @@
"-sASSERTIONS",
"-sWASM_BIGINT",
"-pthread",
"-sFILESYSTEM=0"
"-sFILESYSTEM=0",
"-sALLOW_MEMORY_GROWTH=1",
"-sSTACK_SIZE=1mb",
"-sEXPORTED_RUNTIME_METHODS=cwrap",
"-sMODULARIZE=1",
"-sEXPORT_NAME=\"flecs_tests\""
]
}
],

View File

@ -9,6 +9,10 @@
"webgpu.h": "c",
"html5.h": "c",
"emscripten.h": "c",
"stddef.h": "c"
"stddef.h": "c",
"flecs.h": "c",
"stdlib.h": "c",
"math.h": "c",
"stdio.h": "c"
}
}

View File

@ -1 +1 @@
emcc -O3 src/main.c -o app.html -sUSE_WEBGL2 -sWASM_BIGINT -pthread -I../sokol -I../sokol_gp --shell-file=shell.html -sFILESYSTEM=0
emcc -O3 src/main.c -o app.html -sUSE_WEBGL2 -sWASM_BIGINT -pthread -I../sokol -I../sokol_gp -I../flecs/distr --shell-file=shell.html -sFILESYSTEM=0

View File

@ -1 +1 @@
emcc src/main.c -o app.html -sUSE_WEBGL2 -sASSERTIONS -sWASM_BIGINT -pthread -I../sokol -I../sokol_gp --shell-file=shell.html -sFILESYSTEM=0 -g
emcc src/main.c -o app.html -sUSE_WEBGL2 -sASSERTIONS -sWASM_BIGINT -pthread -I../sokol -I../sokol_gp -I../flecs/distr --shell-file=shell.html -sFILESYSTEM=0 -g

View File

@ -3,15 +3,20 @@
// Includes Sokol GFX, Sokol GP and Sokol APP, doing all implementations.
#define SOKOL_IMPL
#define SOKOL_GLES3
#define FLECS_CUSTOM_BUILD
#include "sokol_gfx.h"
#include "sokol_gp.h"
#include "sokol_app.h"
#include "sokol_glue.h"
#include "flecs.c"
#include <stdio.h> // for fprintf()
#include <stdlib.h> // for exit()
#include <math.h> // for sinf() and cosf()
ecs_world_t *world;
// Called on every frame of the application.
static void frame(void) {
// Get current window size.
@ -68,10 +73,14 @@ static void init(void) {
fprintf(stderr, "Failed to create Sokol GP context: %s\n", sgp_get_error_message(sgp_get_last_error()));
exit(-1);
}
world = ecs_init();
}
// Called when the application is shutting down.
static void cleanup(void) {
ecs_fini(world);
// Cleanup Sokol GP and Sokol GFX resources.
sgp_shutdown();
sg_shutdown();