Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion examples/application/source/platform_glfw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct PlatformGLFW final
void FinishFrame() override;
void Quit() override;

float GetDisplayScaleFactor();
void UpdatePixelDensity();

Application& m_Application;
Expand Down Expand Up @@ -265,6 +266,15 @@ void PlatformGLFW::Quit()
glfwPostEmptyEvent();
}

float PlatformGLFW::GetDisplayScaleFactor() {
float xscale = 1.f;
float yscale = 1.f;
auto monitor = glfwGetPrimaryMonitor();
if (monitor)
glfwGetMonitorContentScale(monitor, &xscale, &yscale);
return 0.5f * (xscale + yscale);
}

void PlatformGLFW::UpdatePixelDensity()
{
float xscale, yscale;
Expand All @@ -275,7 +285,7 @@ void PlatformGLFW::UpdatePixelDensity()
float windowScale = scale;
float framebufferScale = scale;
# else
float windowScale = 1.0f;
float windowScale = GetDisplayScaleFactor();
float framebufferScale = scale;
# endif

Expand Down
2 changes: 1 addition & 1 deletion imgui_extra_math.inl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ inline ImVec2 operator*(const float lhs, const ImVec2& rhs)
return ImVec2(lhs * rhs.x, lhs * rhs.y);
}

inline static ImVec2 operator-(const ImVec2& lhs)
inline ImVec2 operator-(const ImVec2& lhs)
{
return ImVec2(-lhs.x, -lhs.y);
}
Expand Down