@brief It calculates the dpi factor using the density from GLFW physical size GLFW docs for dpi
| 381 | /// @brief It calculates the dpi factor using the density from GLFW physical size |
| 382 | /// <a href="https://www.glfw.org/docs/latest/monitor_guide.html#monitor_size">GLFW docs for dpi</a> |
| 383 | float GlfwWindow::get_dpi_factor() const |
| 384 | { |
| 385 | auto primary_monitor = glfwGetPrimaryMonitor(); |
| 386 | auto vidmode = glfwGetVideoMode(primary_monitor); |
| 387 | |
| 388 | int width_mm, height_mm; |
| 389 | glfwGetMonitorPhysicalSize(primary_monitor, &width_mm, &height_mm); |
| 390 | |
| 391 | // As suggested by the GLFW monitor guide |
| 392 | static const float inch_to_mm = 25.0f; |
| 393 | static const float win_base_density = 96.0f; |
| 394 | |
| 395 | auto dpi = static_cast<uint32_t>(vidmode->width / (width_mm / inch_to_mm)); |
| 396 | auto dpi_factor = dpi / win_base_density; |
| 397 | return dpi_factor; |
| 398 | } |
| 399 | |
| 400 | float GlfwWindow::get_content_scale_factor() const |
| 401 | { |
no outgoing calls
no test coverage detected