-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

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;
}
}