diff --git a/profiler/build/wasm/build.mk b/profiler/build/wasm/build.mk index 578b14e5..889eaac3 100644 --- a/profiler/build/wasm/build.mk +++ b/profiler/build/wasm/build.mk @@ -5,7 +5,7 @@ CFLAGS += -sUSE_FREETYPE=1 -pthread CXXFLAGS := $(CFLAGS) -std=c++17 DEFINES += -DIMGUI_ENABLE_FREETYPE -DIMGUI_IMPL_OPENGL_ES2 INCLUDES := -I../../../imgui -I$(HOME)/.emscripten_cache/sysroot/include/capstone -LIBS += -lpthread -ldl $(HOME)/.emscripten_cache/sysroot/lib/libcapstone.a -sUSE_GLFW=3 -sTOTAL_MEMORY=512mb -sWASM_BIGINT=1 -sPTHREAD_POOL_SIZE=4 --preload-file embed.tracy +LIBS += -lpthread -ldl $(HOME)/.emscripten_cache/sysroot/lib/libcapstone.a -sUSE_GLFW=3 -sTOTAL_MEMORY=512mb -sWASM_BIGINT=1 -sPTHREAD_POOL_SIZE=4 -sEXPORTED_FUNCTIONS=_main,_nativeResize -sEXPORTED_RUNTIME_METHODS=ccall --preload-file embed.tracy PROJECT := Tracy IMAGE := $(PROJECT)-$(BUILD).html diff --git a/profiler/build/wasm/index.html b/profiler/build/wasm/index.html index a1ede838..008eebe4 100644 --- a/profiler/build/wasm/index.html +++ b/profiler/build/wasm/index.html @@ -90,6 +90,10 @@ var preloadElement = document.getElementById('preload'); var canvasElement = document.getElementById('canvas'); + function resizeHandler() { + Module.ccall('nativeResize', 'number', ['number', 'number'], [window.innerWidth, window.innerHeight]); + } + var Module = { preRun: [], postRun: [], @@ -129,11 +133,10 @@ progressElement.max = null; progressElement.hidden = true; preloadElement.hidden = true; - if (!text) spinnerElement.style.display = 'none'; - /* - canvasElement.width = window.innerWidth; - canvasElement.height = window.innerHeight; - */ + if (!text) { + spinnerElement.style.display = 'none'; + resizeHandler(); + } } statusElement.innerHTML = text; }, @@ -152,15 +155,8 @@ if (text) console.error('[post-exception status] ' + text); }; }; - /* - addEventListener('resize', (event) => { - canvasElement.width = window.innerWidth; - canvasElement.height = window.innerHeight; - }); - */ + addEventListener('resize', resizeHandler); - - diff --git a/profiler/src/BackendGlfw.cpp b/profiler/src/BackendGlfw.cpp index 5d19ba24..27785c9b 100644 --- a/profiler/src/BackendGlfw.cpp +++ b/profiler/src/BackendGlfw.cpp @@ -199,3 +199,11 @@ float Backend::GetDpiScale() #endif return 1; } + +#ifdef __EMSCRIPTEN__ +extern "C" int nativeResize( int width, int height ) +{ + glfwSetWindowSize( s_window, width, height ); + return 0; +} +#endif