int main(int argc, char *argv[]) { // GLFW Initialization if(!glfwInit()) { fprintf(stderr, "Failed to initialize GLFW\n"); return EXIT_FAILURE; } glfwSetErrorCallback(ErrorCallback); // hint GLFW that we would like an OpenGL 3 context (at least) // http://www.glfw.org/faq.html#how-do-i-create-an-opengl-30-context glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // attempt to open the window: fails if required version unavailable // note some Intel GPUs do not support OpenGL 3.2 // note update the driver of your graphic card GLFWwindow* window = glfwCreateWindow(512, 512, "spiral", NULL, NULL); if(!window) { glfwTerminate(); return EXIT_FAILURE; } // makes the OpenGL context of window current on the calling thread glfwMakeContextCurrent(window); // set the callback for escape key glfwSetKeyCallback(window, KeyCallback); // GLEW Initialization (must have a context) // https://www.opengl.org/wiki/OpenGL_Loading_Library glewExperimental = GL_TRUE; // fixes glew error (see above link) if(glewInit() != GLEW_NO_ERROR) { fprintf( stderr, "Failed to initialize GLEW\n"); return EXIT_FAILURE; } cout << "OpenGL" << glGetString(GL_VERSION) << endl; // initialize our OpenGL program Init(); // render loop while(!glfwWindowShouldClose(window)) { Display(); glfwSwapBuffers(window); glfwPollEvents(); } triangle.Cleanup(); // close OpenGL window and terminate GLFW glfwDestroyWindow(window); glfwTerminate(); return EXIT_SUCCESS; }