Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

display_scale_factor error and extern static error #254

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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