-improved WASM compilation scripts

-added external bindbc.sdl import for WASM
-working on demos (WIP, working simple demo with ECS and SDL2)
-small change in ecs.std
This commit is contained in:
Mergul 2019-11-06 20:38:46 +01:00
parent a8c74d5045
commit 73f2aa6861
60 changed files with 9015 additions and 67 deletions

50
demos/utils/dub.json Normal file
View file

@ -0,0 +1,50 @@
{
"name": "ecs_utils",
"authors": [
"Michał Masiukiewicz", "Dawid Masiukiewicz"
],
"description": "Dynamic Entity Component System examples utils",
"copyright": "Copyright © 2018-2019, Michał Masiukiewicz, Dawid Masiukiewicz",
"license": "BSD",
"sourcePaths" : [
"source\/"
],
"importPaths": [
"source"
],
"dflags-posix-ldc": [
"-defaultlib=phobos2-ldc,druntime-ldc"
],
"dflagss": [
"-betterC"
],
"dependencies": {
"bindbc-sdl":"0.10.1"
},
"versions": [
"BindSDL_Image",
"SDL_2010"
],
"configurations" : [
{
"name" : "default",
"targetType" : "library",
"subConfigurations":
{
"bindbc-sdl": "static"
}
},
{
"name" : "betterC",
"targetType" : "library",
"dflags": [
"-betterC"
],
"subConfigurations":
{
"bindbc-sdl": "staticBC"
}
}
]
}

View file

@ -0,0 +1,6 @@
module ecs_utils.math.matrix;
struct mat3
{
float[9] data;
}

View file

@ -0,0 +1,100 @@
module ecs_utils.math.vector;
struct vec2
{
union
{
struct
{
float x;
float y;
}
float[2] data;
}
vec2 opBinary(string op)(vec2 v)
{
static if (op == "+") return vec2(x + v.x, y + v.y);
else static if (op == "-") return vec2(x - v.x, y - v.y);
else static if (op == "*") return vec2(x * v.x, y * v.y);
else static if (op == "/") return vec2(x / v.x, y / v.y);
else static assert(0, "Operator "~op~" not implemented");
}
vec2 opBinary(string op)(float v)
{
static if (op == "+") return vec2(x + v, y + v);
else static if (op == "-") return vec2(x - v, y - v);
else static if (op == "*") return vec2(x * v, y * v);
else static if (op == "/") return vec2(x / v, y / v);
else static assert(0, "Operator "~op~" not implemented");
}
void opOpAssign(string op)(vec2 v)
{
static if (op == "+")
{
x += v.x;
y += v.y;
}
else static if (op == "-")
{
x -= v.x;
y -= v.y;
}
else static if (op == "*")
{
x *= v.x;
y *= v.y;
}
else static if (op == "/")
{
x /= v.x;
y /= v.y;
}
else static assert(0, "Operator "~op~" not implemented");
}
}
struct vec4
{
union
{
struct
{
float x;
float y;
float z;
float w;
}
float[4] data;
}
}
struct ivec2
{
union
{
struct
{
int x;
int y;
}
int[2] data;
}
}
struct ivec4
{
union
{
struct
{
int x;
int y;
int z;
int w;
}
int[4] data;
}
}