From 9d42e146e7e094ad1aba51b81f8f9693ed5b9157 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Fri, 30 Sep 2016 03:44:13 +0200 Subject: [PATCH] Add aspect ratio to monitor test mode listing --- tests/monitors.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/monitors.c b/tests/monitors.c index d1d58106..d8d52f77 100644 --- a/tests/monitors.c +++ b/tests/monitors.c @@ -49,14 +49,21 @@ static void usage(void) printf(" monitors -h\n"); } +static int euclid(int a, int b) +{ + return b ? euclid(b, a % b) : a; +} + static const char* format_mode(const GLFWvidmode* mode) { static char buffer[512]; + const int gcd = euclid(mode->width, mode->height); sprintf(buffer, - "%i x %i x %i (%i %i %i) %i Hz", + "%i x %i x %i (%i:%i) (%i %i %i) %i Hz", mode->width, mode->height, mode->redBits + mode->greenBits + mode->blueBits, + mode->width / gcd, mode->height / gcd, mode->redBits, mode->greenBits, mode->blueBits, mode->refreshRate);