Skip to content

Commit

Permalink
try dpi fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ottojo committed Jun 7, 2024
1 parent 83f37b5 commit 800e3d9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ find_package(rclcpp REQUIRED)
include(FetchContent)
FetchContent_Declare(imgui
GIT_REPOSITORY https://github.com/ocornut/imgui.git
GIT_TAG v1.89.8-docking
GIT_TAG v1.90.8-docking
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
)
Expand Down
17 changes: 17 additions & 0 deletions src/rig_reconfigure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ int main(int argc, char *argv[]) {
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);

float highDPIscaleFactor = 1.0;
{
GLFWmonitor *monitor = glfwGetPrimaryMonitor();
float xscale, yscale;
glfwGetMonitorContentScale(monitor, &xscale, &yscale);
if (xscale > 1 || yscale > 1)
{
highDPIscaleFactor = xscale;
glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);
}
}

// Setup Dear ImGui context
IMGUI_CHECKVERSION();
ImGui::CreateContext();
Expand Down Expand Up @@ -109,6 +121,11 @@ int main(int argc, char *argv[]) {

// Setup Dear ImGui style
ImGui::StyleColorsDark();
ImGui::GetStyle().ScaleAllSizes(highDPIscaleFactor);
ImFontConfig config;
config.SizePixels = 13.0f * highDPIscaleFactor;
ImGui::GetIO().Fonts->AddFontDefault(&config);
//ImGui::GetIO().Fonts->AddFontFromFileTTF("ProggyClean.ttf", 13.0f * highDPIscaleFactor, NULL, NULL);

// Setup Platform/Renderer backends
ImGui_ImplGlfw_InitForOpenGL(window, true);
Expand Down

0 comments on commit 800e3d9

Please sign in to comment.