Advertisement
Guest User

Testing GLFW

a guest
Dec 21st, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.26 KB | None | 0 0
  1. #include <GLFW/glfw3.h>
  2. #include <stdio.h>
  3.  
  4. #define STR(x)   #x
  5. #define SHOW_DEFINE(x) printf("%s=%s\n", #x, STR(x))
  6.  
  7. int main(void)
  8. {
  9.     GLFWwindow* window;
  10.  
  11.     /* Initialize the library */
  12.     if (!glfwInit())
  13.         return -1;
  14.    
  15.     SHOW_DEFINE(GLFW_VERSION_MAJOR);
  16.     SHOW_DEFINE(GLFW_VERSION_MINOR);
  17.     SHOW_DEFINE(GLFW_VERSION_REVISION);
  18.    
  19.     glfwWindowHint(GLFW_VISIBLE, 0);
  20.     glfwWindowHint(GLFW_RESIZABLE, 1);
  21.    
  22.     printf("Creating window:\n");
  23.     /* Create a windowed mode window and its OpenGL context */
  24.     window = glfwCreateWindow(300, 300, "Hello World", NULL, NULL);
  25.     if (!window)
  26.     {
  27.         glfwTerminate();
  28.         printf("Failed to create window\n");
  29.         return -1;
  30.     }
  31.     printf("Window created\n");
  32.    
  33.     glfwShowWindow(window);
  34.  
  35.     /* Make the window's context current */
  36.     glfwMakeContextCurrent(window);
  37.     printf("Made context current\n");
  38.  
  39.     /* Loop until the user closes the window */
  40.     while (!glfwWindowShouldClose(window))
  41.     {
  42.         /* Render here */
  43.  
  44.         /* Swap front and back buffers */
  45.         glfwSwapBuffers(window);
  46.  
  47.         /* Poll for and process events */
  48.         glfwPollEvents();
  49.     }
  50.     printf("exit...\n");
  51.  
  52.     glfwTerminate();
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement