Support hidpi.

This commit is contained in:
Bartosz Taudul 2022-10-02 13:51:28 +02:00
parent 4b5a823d39
commit cf61fbf7ba
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 6 additions and 2 deletions

View File

@ -91,7 +91,9 @@
var canvasElement = document.getElementById('canvas');
function resizeHandler() {
Module.ccall('nativeResize', 'number', ['number', 'number'], [window.innerWidth, window.innerHeight]);
Module.ccall('nativeResize', 'number', ['number', 'number'], [window.innerWidth * window.devicePixelRatio, window.innerHeight * window.devicePixelRatio]);
Module.canvas.style.width = window.innerWidth + 'px';
Module.canvas.style.height = window.innerHeight + 'px';
}
var Module = {

View File

@ -187,7 +187,9 @@ void Backend::SetTitle( const char* title )
float Backend::GetDpiScale()
{
#if GLFW_VERSION_MAJOR > 3 || ( GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 3 )
#ifdef __EMSCRIPTEN__
return EM_ASM_DOUBLE( { return window.devicePixelRatio; } );
#elif GLFW_VERSION_MAJOR > 3 || ( GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 3 )
auto monitor = glfwGetWindowMonitor( s_window );
if( !monitor ) monitor = glfwGetPrimaryMonitor();
if( monitor )