-make tests working on web
-WebAssembly now is compiled with emscripten use (stdc functions bindings only) -added python script to build WASM version
This commit is contained in:
parent
015783bf5c
commit
a8c74d5045
5 changed files with 158 additions and 23 deletions
|
|
@ -14,15 +14,52 @@ import ecs.core;
|
|||
|
||||
version(WebAssembly)
|
||||
{
|
||||
extern(C) void printf(const char *format, ...) @nogc nothrow @system;
|
||||
struct Time
|
||||
extern(C) int printf(scope const char* format, ...) @nogc nothrow @system;
|
||||
/*{
|
||||
return 0;
|
||||
}*/
|
||||
//import core.stdc.stdio : printf;
|
||||
/*struct Time
|
||||
{
|
||||
static long getUSecTime()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}*/
|
||||
|
||||
alias int time_t;
|
||||
alias int clockid_t;
|
||||
enum CLOCK_REALTIME = 0;
|
||||
|
||||
struct timespec
|
||||
{
|
||||
time_t tv_sec;
|
||||
int tv_nsec;
|
||||
}
|
||||
|
||||
extern(C) int clock_gettime(clockid_t, timespec*) @nogc nothrow @system;
|
||||
|
||||
struct Time
|
||||
{
|
||||
|
||||
|
||||
static long getUSecTime()
|
||||
{
|
||||
time_t time;
|
||||
timespec spec;
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &spec);
|
||||
|
||||
//time = spec.tv_sec;
|
||||
return spec.tv_sec * 1000_000 + spec.tv_nsec / 1000;//time / 1000_000;
|
||||
|
||||
/*LARGE_INTEGER time, freq;
|
||||
QueryPerformanceFrequency(&freq);
|
||||
QueryPerformanceCounter(&time);
|
||||
return time.QuadPart / (freq.QuadPart / 1000_000);*/
|
||||
}
|
||||
}
|
||||
|
||||
extern(C) void _start() {}
|
||||
}
|
||||
else version(Windows)
|
||||
|
|
@ -195,20 +232,20 @@ struct ChangeTestSystem
|
|||
{
|
||||
//printf("Entity added! ID: ");
|
||||
foreach (i; 0 .. data.length)
|
||||
printf("Entity added! ID: %u\n",data.entites[i].id);
|
||||
printf("Entity added! ID: %u\n",cast(uint)data.entites[i].id.id);
|
||||
////writeln("Entity added! ID: ", data.entites[i].id);
|
||||
}
|
||||
|
||||
void onRemoveEntity(EntitiesData data)
|
||||
{
|
||||
////writeln("Entity removed! ID: ", data.entites[0].id);
|
||||
printf("Entity removed! ID: %u\n",data.entites[0].id);
|
||||
printf("Entity removed! ID: %u\n",cast(uint)data.entites[0].id.id);
|
||||
}
|
||||
|
||||
void onChangeEntity(EntitiesData data)
|
||||
{
|
||||
////writeln("Entity changed! ID: ", data.entites[0].id);
|
||||
printf("Entity changed! ID: %u\n",data.entites[0].id);
|
||||
printf("Entity changed! ID: %u\n",cast(uint)data.entites[0].id.id);
|
||||
}
|
||||
|
||||
bool onBegin()
|
||||
|
|
@ -299,8 +336,8 @@ struct TestSystem
|
|||
|
||||
void onUpdate(ref Entity entity, ref TestComp test, ref TestComp2 test2) //, TestComp3* test3) //ref TestComp comp)
|
||||
{
|
||||
assert(cast(size_t)&test % TestComp.alignof == 0);
|
||||
assert(cast(size_t)&test2 % TestComp2.alignof == 0);
|
||||
//assert(cast(size_t)&test % TestComp.alignof == 0);
|
||||
//assert(cast(size_t)&test2 % TestComp2.alignof == 0);
|
||||
|
||||
test.a += 1000;
|
||||
test.b += 2000;
|
||||
|
|
@ -504,6 +541,8 @@ struct TestSystem2
|
|||
extern(C) int main()
|
||||
{
|
||||
|
||||
|
||||
|
||||
void dispatch(EntityManager.JobGroup jobs) nothrow @nogc
|
||||
{
|
||||
foreach (job; jobs.jobs)
|
||||
|
|
@ -516,28 +555,32 @@ extern(C) int main()
|
|||
void writeEntityComponents(Entity* entity)
|
||||
{
|
||||
|
||||
printf("EntityID(%u, %u)",entity.id.id,entity.id.counter);
|
||||
printf("EntityID(%u, %u)",cast(uint)entity.id.id,cast(uint)entity.id.counter);
|
||||
//write(entity.id);
|
||||
TestComp* test_comp = entity.getComponent!TestComp;
|
||||
if (test_comp)
|
||||
printf("TestComp(%u, %u)",test_comp.a,test_comp.b);//write(*test_comp);
|
||||
printf("TestComp(%u, %u)",cast(uint)test_comp.a,cast(uint)test_comp.b);//write(*test_comp);
|
||||
TestComp2* test_comp2 = entity.getComponent!TestComp2;
|
||||
if (test_comp2)
|
||||
printf("TestComp2(%u, %u)",test_comp2.b,test_comp2.a);//write(*test_comp2);
|
||||
printf("TestComp2(%u, %u)",cast(uint)test_comp2.b,cast(uint)test_comp2.a);//write(*test_comp2);
|
||||
TestComp3* test_comp3 = entity.getComponent!TestComp3;
|
||||
if (test_comp3)
|
||||
printf("TestComp3(%u, %u)",test_comp3.gg,test_comp3.bg);//write(*test_comp3);
|
||||
printf("TestComp3(%u, %u)",cast(uint)test_comp3.gg,cast(uint)test_comp3.bg);//write(*test_comp3);
|
||||
TestComp4* test_comp4 = entity.getComponent!TestComp4;
|
||||
if (test_comp4)
|
||||
printf("TestComp4(%u, %u, %u, %u, %u, %u)",test_comp4.gg,test_comp4.bg,test_comp4.a,test_comp4.b,test_comp4.c,test_comp4.g);//write(*test_comp4);
|
||||
printf("TestComp4(%u, %u, %u, %u, %u, %u)",test_comp4.gg,test_comp4.bg,cast(uint)test_comp4.a,cast(uint)test_comp4.b,cast(uint)test_comp4.c,cast(uint)test_comp4.g);//write(*test_comp4);
|
||||
printf("\n");
|
||||
//writeln();
|
||||
////writeln((cast(uint*) pp)[0 .. 14], " ", pp);
|
||||
}
|
||||
|
||||
/*int a = 0;
|
||||
if(!a)assert(0);*/
|
||||
|
||||
EntityManager.initialize(1);
|
||||
|
||||
gEM.setJobDispachFunc(&dispatch);
|
||||
assert(gEM !is null);
|
||||
//assert(gEM !is null);
|
||||
|
||||
gEM.beginRegister();
|
||||
gEM.registerPass("fixed");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue