text: //
  //  hellowindow2.cpp
  //  MYLearnOpenGL
  //
  //  Created by admin on 16/12/2.
  //  Copyright © 2016年 zsr. All rights reserved.
  //
  
  #include <iostream>
  #include <GL/glew.h>
  #include <GLFW/glfw3.h>
  
  void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode);
  const GLuint WIDTH = 800, HEIGHT = 600;
  
  int main()
  {
      std::cout << "Starting GLFW context, OpenGL 3.3" << std::endl;
      glfwInit();
      glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
      glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
      glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
      glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
      glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
      GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "LearnOpenGL", nullptr, nullptr);
      glfwMakeContextCurrent(window);
      if (window == NULL)
      {
          std::cout << "Failed to create GLFW window" << std::endl;
          glfwTerminate();
          return -1;
      }
      
      glfwSetKeyCallback(window, key_callback);
      
      glewExperimental = GL_TRUE;
      if (glewInit() != GLEW_OK)
      {
          std::cout << "Failed to initialize GLEW" << std::endl;
          return -1;
      }
      
      glViewport(0, 0, WIDTH, HEIGHT);
      
      while (!glfwWindowShouldClose(window))
      {
          glfwPollEvents();
          
          glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
          glClear(GL_COLOR_BUFFER_BIT);
          glfwSwapBuffers(window);
      }
      
      glfwTerminate();
      return 0;
  }
  
  void key_callback(GLFWwindow* window, int key, int scancode, int action, int mode)
  {
      std::cout << key << std::endl;
      if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
          glfwSetWindowShouldClose(window, GL_TRUE);
  }
  