AllenYuan

window - create window - opengl

Apr 21st, 2020
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1.   // initialize GLEW so we can make OpenGL calls. Print an error and close the window if it fails
  2.   GLenum err = glewInit();
  3.   if(err != GLEW_OK)
  4.   {
  5.     fprintf(stderr, "Error initializing GLEW.\n");
  6.     glfwTerminate();
  7.     return -1;
  8.   }
  9.  
  10.   // if we see the below log statements, we've successfully attached OpenGL to the window
  11.   // query the openGL version
  12.   int glVersion[2] = {-1, 1};
  13.   glGetIntegerv(GL_MAJOR_VERSION, &glVersion[0]);
  14.   glGetIntegerv(GL_MINOR_VERSION, &glVersion[1]);
  15.  
  16.   // on error, log filepath and line number
  17.   gl_debug(__FILE__, __LINE__);
  18.   // print some information about our version of OpenGL.
  19.   printf("Using OpenGL: %d.%d\n", glVersion[0], glVersion[1]);
  20.   printf("Renderer used: %s\n", glGetString(GL_RENDERER));
  21.   printf("Shading Language: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
  22.  
  23.   return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment