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

fix dpi scaling bs #38

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