-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,49 @@
module utils.texture;
import ecs.std;
import bindbc.sdl;
import bindbc.sdl.image;
import ecs_utils.math.vector;
struct Texture
{
void create()
{
data = Mallocator.make!Data;
}
bool load(SDL_Renderer* renderer, const char[] path)
{
char[] cpath = (cast(char*)alloca(path.length+1))[0..path.length+1];
//cpath[0..$-1] = path[0..$];
memcpy(cpath.ptr, path.ptr, path.length);
cpath[$-1] = 0;
SDL_Surface* surf = IMG_Load(cpath.ptr);
if(!surf)return false;
data.size = ivec2(surf.w,surf.h);
data.texture = SDL_CreateTextureFromSurface(renderer,surf);
SDL_FreeSurface(surf);
if(!data.texture)return false;
return true;
}
struct Data
{
ubyte[] data;
ivec2 size;
uint bpp;
SDL_Texture* texture;
}
Data* data;
}