1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-23 10:48:51 -05:00
glfw/tests/defaults.c

105 lines
3.2 KiB
C
Raw Normal View History

2010-09-07 11:34:51 -04:00
//========================================================================
// Default window/context test
// Copyright (c) Camilla Berglund <elmindreda@elmindreda.org>
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would
// be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not
// be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source
// distribution.
//
//========================================================================
//
// This test creates a windowed mode window with all parameters set to
// default values and then reports the actual parameters of the created
// window and context
//
//========================================================================
#include <GL/glfw3.h>
2010-09-07 11:34:51 -04:00
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
int param;
char* name;
} Param;
static Param parameters[] =
{
{ GLFW_ACCELERATED, "accelerated" },
{ GLFW_RED_BITS, "red bits" },
{ GLFW_GREEN_BITS, "green bits" },
{ GLFW_BLUE_BITS, "blue bits" },
{ GLFW_ALPHA_BITS, "alpha bits" },
{ GLFW_DEPTH_BITS, "depth bits" },
{ GLFW_STENCIL_BITS, "stencil bits" },
{ GLFW_REFRESH_RATE, "refresh rate" },
{ GLFW_ACCUM_RED_BITS, "accum red bits" },
{ GLFW_ACCUM_GREEN_BITS, "accum green bits" },
{ GLFW_ACCUM_BLUE_BITS, "accum blue bits" },
{ GLFW_ACCUM_ALPHA_BITS, "accum alpha bits" },
{ GLFW_AUX_BUFFERS, "aux buffers" },
{ GLFW_STEREO, "stereo" },
{ GLFW_FSAA_SAMPLES, "FSAA samples" },
{ GLFW_OPENGL_VERSION_MAJOR, "OpenGL major" },
{ GLFW_OPENGL_VERSION_MINOR, "OpenGL minor" },
{ GLFW_OPENGL_FORWARD_COMPAT, "OpenGL forward compatible" },
{ GLFW_OPENGL_DEBUG_CONTEXT, "OpenGL debug context" },
{ GLFW_OPENGL_PROFILE, "OpenGL profile" },
};
int main(void)
{
int i, width, height;
GLFWwindow window;
2010-09-07 11:34:51 -04:00
if (!glfwInit(NULL))
2010-09-07 11:34:51 -04:00
{
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
2011-09-08 16:47:37 -04:00
exit(EXIT_FAILURE);
2010-09-07 11:34:51 -04:00
}
2010-10-04 12:17:53 -04:00
window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "Defaults", NULL);
if (!window)
2010-09-07 11:34:51 -04:00
{
glfwTerminate();
fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
2011-09-08 16:47:37 -04:00
exit(EXIT_FAILURE);
2010-09-07 11:34:51 -04:00
}
glfwGetWindowSize(window, &width, &height);
2010-09-07 11:34:51 -04:00
printf("window size: %ix%i\n", width, height);
for (i = 0; (size_t) i < sizeof(parameters) / sizeof(parameters[0]); i++)
{
printf("%s: %i\n",
parameters[i].name,
glfwGetWindowParam(window, parameters[i].param));
2010-09-07 11:34:51 -04:00
}
glfwCloseWindow(window);
window = NULL;
2010-09-07 11:34:51 -04:00
glfwTerminate();
2011-09-08 16:47:37 -04:00
exit(EXIT_SUCCESS);
2010-09-07 11:34:51 -04:00
}