glfw/tests/listmodes.c

62 lines
2.0 KiB
C
Raw Normal View History

2010-09-07 15:34:51 +00:00
//========================================================================
// This is a small test application for GLFW.
// The program lists all available fullscreen video modes.
//========================================================================
#include <GL/glfw3.h>
2010-09-07 15:34:51 +00:00
2011-09-19 18:36:01 +00:00
#include <stdio.h>
#include <stdlib.h>
2010-09-07 15:34:51 +00:00
2011-09-19 18:36:01 +00:00
static void print_mode(GLFWvidmode* mode)
{
printf("%i x %i x %i (%i %i %i)\n",
mode->width, mode->height,
mode->redBits + mode->greenBits + mode->blueBits,
mode->redBits, mode->greenBits, mode->blueBits);
}
2010-09-07 15:34:51 +00:00
2011-09-19 18:36:01 +00:00
int main(void)
2010-09-07 15:34:51 +00:00
{
GLFWdisplay displayHandle;
2011-09-19 18:36:01 +00:00
GLFWvidmode dtmode, modes[400];
int modecount, i;
2010-09-07 15:34:51 +00:00
2011-09-19 18:36:01 +00:00
if (!glfwInit())
2010-09-07 15:34:51 +00:00
{
2011-09-19 18:36:01 +00:00
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
exit(EXIT_FAILURE);
2010-09-07 15:34:51 +00:00
}
// Show desktop video mode
2011-09-19 18:36:01 +00:00
glfwGetDesktopMode(&dtmode);
printf("Desktop mode: ");
print_mode(&dtmode);
2010-09-07 15:34:51 +00:00
displayHandle = GLFW_DISPLAY_INVALID_HANDLE;
while( GLFW_DISPLAY_INVALID_HANDLE != ( displayHandle = glfwGetNextDisplay( displayHandle )))
2010-09-07 15:34:51 +00:00
{
printf( "Display name: %s\n"
"Physical dimensions: %dmm x %dmm\n"
"Logical position: (%d,%d)\n",
glfwGetDisplayStringParam( displayHandle, GLFW_DISPLAY_PARAM_S_NAME ),
glfwGetDisplayIntegerParam( displayHandle, GLFW_DISPLAY_PARAM_I_PHYS_WIDTH ),
glfwGetDisplayIntegerParam( displayHandle, GLFW_DISPLAY_PARAM_I_PHYS_HEIGHT ),
glfwGetDisplayIntegerParam( displayHandle, GLFW_DISPLAY_PARAM_I_SCREEN_X_POS ),
glfwGetDisplayIntegerParam( displayHandle, GLFW_DISPLAY_PARAM_I_SCREEN_Y_POS )
);
// List available video modes
modecount = glfwGetVideoModes(displayHandle, modes, sizeof(modes) / sizeof(GLFWvidmode));
printf( "Available modes:\n" );
for( i = 0; i < modecount; i ++ )
{
printf("%3i: ", i);
print_mode(modes + i);
}
2010-09-07 15:34:51 +00:00
}
glfwTerminate();
2011-09-19 18:36:01 +00:00
exit(EXIT_SUCCESS);
2010-09-07 15:34:51 +00:00
}
2011-09-19 18:36:01 +00:00