emscripten / webasm full support

main
Brett 2024-04-26 18:05:00 -04:00
parent c76d16eacd
commit ba3735f83b
4 changed files with 16 additions and 7 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.25)
project(graphs VERSION 0.0.15)
project(graphs VERSION 0.0.16)
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)
@ -38,5 +38,6 @@ if (${ENABLE_TSAN} MATCHES ON)
endif ()
if (EMSCRIPTEN)
set_target_properties(graphs PROPERTIES LINK_FLAGS "-sMAX_WEBGL_VERSION=2 -sASSERTIONS=1 -sUSE_GLFW=3")
set(BLT_PRELOAD_PATH "../res@../res")
include(lib/BLT-With-Graphics-Template/cmake/link_flags.cmake)
endif ()

View File

@ -1,5 +1,6 @@
#!/bin/bash
cd cmake-build-emrelwithdebinfo
emcmake cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ../
#emcmake cmake -DCMAKE_BUILD_TYPE=Release ../
emmake make -j 16
cp graphs.js graphs.wasm /var/www/html
cp graphs.js graphs.data graphs.wasm /var/www/html

@ -1 +1 @@
Subproject commit 7c7e97872da61d43400786e6da2a8d9d65b2e546
Subproject commit 0233ce7549f5d0ef1df53157ed102e48f25c954e

View File

@ -28,13 +28,20 @@ blt::gfx::batch_renderer_2d renderer_2d(resources);
blt::gfx::first_person_camera camera;
blt::gfx::fbo_t render_texture;
#ifdef __EMSCRIPTEN__
std::string resource_prefix = "../";
#else
std::string resource_prefix = "../";
#endif
void init(const blt::gfx::window_context& context)
{
using namespace blt::gfx;
resources.setPrefixDirectory(resource_prefix);
resources.enqueue("./res/debian.png", "debian");
resources.enqueue("./res/parker.png", "parker");
resources.enqueue("./res/parker cat ears.jpg", "parkercat");
resources.enqueue("res/debian.png", "debian");
resources.enqueue("res/parker.png", "parker");
resources.enqueue("res/parker cat ears.jpg", "parkercat");
global_matrices.create_internals();
resources.load_resources();