mirror of
https://github.com/glfw/glfw.git
synced 2026-09-23 00:59:48 +00:00
Add content scale queries
This adds glfwGetWindowContentScale and glfwGetMonitorContentScale for querying the recommended drawing scale factor for DPI-aware rendering. Parts of this patch are based on code by @ferreiradaselva. Fixes #235. Fixes #439. Fixes #677. Fixes #845. Fixes #898.
This commit is contained in:
+6
-3
@@ -92,21 +92,24 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
|
||||
|
||||
static void list_modes(GLFWmonitor* monitor)
|
||||
{
|
||||
int count, x, y, widthMM, heightMM, i;
|
||||
int count, x, y, width_mm, height_mm, i;
|
||||
float xscale, yscale;
|
||||
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
|
||||
const GLFWvidmode* modes = glfwGetVideoModes(monitor, &count);
|
||||
|
||||
glfwGetMonitorPos(monitor, &x, &y);
|
||||
glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM);
|
||||
glfwGetMonitorPhysicalSize(monitor, &width_mm, &height_mm);
|
||||
glfwGetMonitorContentScale(monitor, &xscale, &yscale);
|
||||
|
||||
printf("Name: %s (%s)\n",
|
||||
glfwGetMonitorName(monitor),
|
||||
glfwGetPrimaryMonitor() == monitor ? "primary" : "secondary");
|
||||
printf("Current mode: %s\n", format_mode(mode));
|
||||
printf("Virtual position: %i %i\n", x, y);
|
||||
printf("Content scale: %f %f\n", xscale, yscale);
|
||||
|
||||
printf("Physical size: %i x %i mm (%0.2f dpi)\n",
|
||||
widthMM, heightMM, mode->width * 25.4f / widthMM);
|
||||
width_mm, height_mm, mode->width * 25.4f / width_mm);
|
||||
|
||||
printf("Modes:\n");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user