Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Iterate through various window hint permuations and list the results
- // Copyright (c) 2010 BenXYZ
- //
- // Modified by Camilla Berglund <elmindreda@elmindreda.org>
- #include <stdio.h>
- #include <stdlib.h>
- #include <GL/glfw.h>
- int screenw = 800;
- int screenh = 600;
- #define USE_FORWARD_COMPAT(x) ((x) & 0x01)
- #define USE_CORE_PROFILE(x) ((x) & 0x02)
- int main(int argc, char *argv[])
- {
- if (!glfwInit())
- {
- fprintf(stderr, "Failed to initialise GLFW\n");
- exit(EXIT_FAILURE);
- }
- // Iterate though forward-compat and core profile permuations
- for (int hintswitch = 0; hintswitch < 4; hintswitch++)
- {
- printf("Test run with%s forward-compatibility %s with%s core profile\n",
- USE_FORWARD_COMPAT(hintswitch) ? "" : "out",
- USE_FORWARD_COMPAT(hintswitch) == USE_CORE_PROFILE(hintswitch) ? "and" : "but",
- USE_CORE_PROFILE(hintswitch) ? "" : "out");
- // Iterate through major and minor OpenGL version permuations
- for (int imaj = 1; imaj < 5; imaj++)
- {
- for (int imin = 0; imin < 10; imin++)
- {
- // Set all window hints each time, as glfwOpenWindow resets them
- glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, imaj);
- glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, imin);
- if (USE_FORWARD_COMPAT(hintswitch))
- glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
- if (USE_CORE_PROFILE(hintswitch))
- glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
- printf("OpenGL version: %d.%d ", imaj, imin);
- // Try to create the desired context
- if (glfwOpenWindow(screenw, screenh, 0, 0, 0, 0, 0, 0, GLFW_WINDOW) == GL_TRUE)
- {
- printf("works\t(reports %d.%d)\n",
- glfwGetWindowParam(GLFW_OPENGL_VERSION_MAJOR),
- glfwGetWindowParam(GLFW_OPENGL_VERSION_MINOR));
- glfwCloseWindow();
- }
- else
- printf("FAILED\n");
- }
- }
- printf("\n");
- }
- exit(EXIT_SUCCESS);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement