Skip to content

Commit d1246e7

Browse files
Emscripten app: set proper imgui framebuffer scale
1 parent 41c345f commit d1246e7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

SampleBase/src/Emscripten/SampleAppEmscripten.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "ImGuiImplEmscripten.hpp"
2929
#include <emscripten.h>
3030
#include <emscripten/html5.h>
31+
#include "imgui.h"
3132

3233
namespace Diligent
3334
{
@@ -49,6 +50,11 @@ class SampleAppEmscripten : public SampleApp
4950

5051
const auto& SCDesc = m_pSwapChain->GetDesc();
5152
m_pImGui = ImGuiImplEmscripten::Create(ImGuiDiligentCreateInfo{m_pDevice, SCDesc});
53+
54+
auto& io = ImGui::GetIO();
55+
auto DevicePixelRatio = static_cast<float>(emscripten_get_device_pixel_ratio());
56+
io.DisplayFramebufferScale = ImVec2{DevicePixelRatio, DevicePixelRatio};
57+
5258
InitializeSample();
5359
}
5460
catch (...)

0 commit comments

Comments
 (0)