diff --git a/source/MaterialXGraphEditor/Main.cpp b/source/MaterialXGraphEditor/Main.cpp index 4661242f8d..ff56e9e96d 100644 --- a/source/MaterialXGraphEditor/Main.cpp +++ b/source/MaterialXGraphEditor/Main.cpp @@ -30,7 +30,7 @@ const std::string options = " --path [FILEPATH] Specify an additional data search path location (e.g. '/projects/MaterialX'). This absolute path will be queried when locating data libraries, XInclude references, and referenced images.\n" " --library [FILEPATH] Specify an additional data library folder (e.g. 'vendorlib', 'studiolib'). This relative path will be appended to each location in the data search path when loading data libraries.\n" " --captureFilename [FILENAME] Specify the filename to which the first rendered frame should be written\n" - " --disableScaling Disable automatic HiDPI scaling\n" + " --scaleFactor [FACTOR] Manually specify a HiDPI scaling factor\n" " --help Display the complete list of command-line options\n"; template void parseToken(std::string token, std::string type, T& res) @@ -66,7 +66,7 @@ int main(int argc, char* const argv[]) mx::FilePathVec libraryFolders; int viewWidth = 256; int viewHeight = 256; - bool disableScaling = false; + float scaleFactor = 0.0; std::string captureFilename; for (size_t i = 0; i < tokens.size(); i++) @@ -102,9 +102,9 @@ int main(int argc, char* const argv[]) { parseToken(nextToken, "string", captureFilename); } - else if (token == "--disableScaling") + else if (token == "--scaleFactor") { - disableScaling = true; + parseToken(nextToken, "float", scaleFactor); } else if (token == "--help") { @@ -199,17 +199,15 @@ int main(int argc, char* const argv[]) // Fonts are not handled, so a global font scale factor is set. // There appears to be no multi-monitor solution so use the primary monitor // for now. - if(!disableScaling) { - GLFWmonitor* monitor = glfwGetPrimaryMonitor(); - if (monitor) - { - float xscale = 1.0f, yscale = 1.0f; - glfwGetMonitorContentScale(monitor, &xscale, &yscale); - ImGuiStyle& style = ImGui::GetStyle(); - float dpiScale = xscale > yscale ? xscale : yscale; - style.ScaleAllSizes(dpiScale); - graph->setFontScale(dpiScale); - } + GLFWmonitor* monitor = glfwGetPrimaryMonitor(); + if (monitor) + { + float xscale = 1.0f, yscale = 1.0f; + glfwGetMonitorContentScale(monitor, &xscale, &yscale); + ImGuiStyle& style = ImGui::GetStyle(); + float dpiScale = scaleFactor == 0.0 ? (xscale > yscale ? xscale : yscale) : scaleFactor; + style.ScaleAllSizes(dpiScale); + graph->setFontScale(dpiScale); } // Create editor config and context.