mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Simplified mode printing.
This commit is contained in:
parent
5527e52f58
commit
6059523b6d
@ -49,12 +49,18 @@ static void usage(void)
|
|||||||
printf(" modes -h\n");
|
printf(" modes -h\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_mode(GLFWvidmode* mode)
|
static const char* format_mode(GLFWvidmode* mode)
|
||||||
{
|
{
|
||||||
printf("%i x %i x %i (%i %i %i)",
|
static char buffer[512];
|
||||||
mode->width, mode->height,
|
|
||||||
mode->redBits + mode->greenBits + mode->blueBits,
|
snprintf(buffer, sizeof(buffer),
|
||||||
mode->redBits, mode->greenBits, mode->blueBits);
|
"%i x %i x %i (%i %i %i)",
|
||||||
|
mode->width, mode->height,
|
||||||
|
mode->redBits + mode->greenBits + mode->blueBits,
|
||||||
|
mode->redBits, mode->greenBits, mode->blueBits);
|
||||||
|
|
||||||
|
buffer[sizeof(buffer) - 1] = '\0';
|
||||||
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void error_callback(int error, const char* description)
|
static void error_callback(int error, const char* description)
|
||||||
@ -109,16 +115,13 @@ static void list_modes(void)
|
|||||||
GLFWvidmode* modes = get_video_modes(&count);
|
GLFWvidmode* modes = get_video_modes(&count);
|
||||||
|
|
||||||
glfwGetDesktopMode(&desktop_mode);
|
glfwGetDesktopMode(&desktop_mode);
|
||||||
printf("Desktop mode: ");
|
printf("Desktop mode: %s\n", format_mode(&desktop_mode));
|
||||||
print_mode(&desktop_mode);
|
|
||||||
putchar('\n');
|
|
||||||
|
|
||||||
printf("Available modes:\n");
|
printf("Available modes:\n");
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
printf("%3u: ", (unsigned int) i);
|
printf("%3u: %s", (unsigned int) i, format_mode(modes + i));
|
||||||
print_mode(modes + i);
|
|
||||||
|
|
||||||
if (memcmp(&desktop_mode, modes + i, sizeof(GLFWvidmode)) == 0)
|
if (memcmp(&desktop_mode, modes + i, sizeof(GLFWvidmode)) == 0)
|
||||||
printf(" (desktop mode)");
|
printf(" (desktop mode)");
|
||||||
@ -147,18 +150,16 @@ static void test_modes(void)
|
|||||||
glfwOpenWindowHint(GLFW_GREEN_BITS, mode->greenBits);
|
glfwOpenWindowHint(GLFW_GREEN_BITS, mode->greenBits);
|
||||||
glfwOpenWindowHint(GLFW_BLUE_BITS, mode->blueBits);
|
glfwOpenWindowHint(GLFW_BLUE_BITS, mode->blueBits);
|
||||||
|
|
||||||
printf("Opening ");
|
printf("Testing mode %u: %s", (unsigned int) i, format_mode(mode));
|
||||||
print_mode(mode);
|
|
||||||
printf(" window\n");
|
|
||||||
|
|
||||||
window = glfwOpenWindow(mode->width, mode->height,
|
window = glfwOpenWindow(mode->width, mode->height,
|
||||||
GLFW_FULLSCREEN, "Video Mode Test",
|
GLFW_FULLSCREEN, "Video Mode Test",
|
||||||
NULL);
|
NULL);
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
printf("Failed to enter mode %u: ", (unsigned int) i);
|
printf("Failed to enter mode %u: %s\n",
|
||||||
print_mode(mode);
|
(unsigned int) i,
|
||||||
putchar('\n');
|
format_mode(mode));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user