Adapt render size to fit browser window.

This commit is contained in:
Bartosz Taudul 2022-10-02 13:35:32 +02:00
parent 73f6e73c51
commit 4b5a823d39
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
3 changed files with 18 additions and 14 deletions

View File

@ -5,7 +5,7 @@ CFLAGS += -sUSE_FREETYPE=1 -pthread
CXXFLAGS := $(CFLAGS) -std=c++17 CXXFLAGS := $(CFLAGS) -std=c++17
DEFINES += -DIMGUI_ENABLE_FREETYPE -DIMGUI_IMPL_OPENGL_ES2 DEFINES += -DIMGUI_ENABLE_FREETYPE -DIMGUI_IMPL_OPENGL_ES2
INCLUDES := -I../../../imgui -I$(HOME)/.emscripten_cache/sysroot/include/capstone 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 PROJECT := Tracy
IMAGE := $(PROJECT)-$(BUILD).html IMAGE := $(PROJECT)-$(BUILD).html

View File

@ -90,6 +90,10 @@
var preloadElement = document.getElementById('preload'); var preloadElement = document.getElementById('preload');
var canvasElement = document.getElementById('canvas'); var canvasElement = document.getElementById('canvas');
function resizeHandler() {
Module.ccall('nativeResize', 'number', ['number', 'number'], [window.innerWidth, window.innerHeight]);
}
var Module = { var Module = {
preRun: [], preRun: [],
postRun: [], postRun: [],
@ -129,11 +133,10 @@
progressElement.max = null; progressElement.max = null;
progressElement.hidden = true; progressElement.hidden = true;
preloadElement.hidden = true; preloadElement.hidden = true;
if (!text) spinnerElement.style.display = 'none'; if (!text) {
/* spinnerElement.style.display = 'none';
canvasElement.width = window.innerWidth; resizeHandler();
canvasElement.height = window.innerHeight; }
*/
} }
statusElement.innerHTML = text; statusElement.innerHTML = text;
}, },
@ -152,15 +155,8 @@
if (text) console.error('[post-exception status] ' + text); if (text) console.error('[post-exception status] ' + text);
}; };
}; };
/* addEventListener('resize', resizeHandler);
addEventListener('resize', (event) => {
canvasElement.width = window.innerWidth;
canvasElement.height = window.innerHeight;
});
*/
</script> </script>
<script async type="text/javascript" src="Tracy-release.js"></script> <script async type="text/javascript" src="Tracy-release.js"></script>
</body> </body>
</html> </html>

View File

@ -199,3 +199,11 @@ float Backend::GetDpiScale()
#endif #endif
return 1; return 1;
} }
#ifdef __EMSCRIPTEN__
extern "C" int nativeResize( int width, int height )
{
glfwSetWindowSize( s_window, width, height );
return 0;
}
#endif