title: glDebugMessageCallback doesn't get called despite of error
body: <p>I am using GLFW and GLEW in a C++ program to work with OpenGL. I want to be able to output OpenGL errors to the console. To test this, I made a little program:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  #include &lt;GL/glew.h&gt;
  #include &lt;GLFW/glfw3.h&gt;
  
  // Test error function
  void GLAPIENTRY MessageCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam) {
      std::cout &lt;&lt; "ERROR";
  }
  
  // Main function
  int main(void)
  {
      // Just some initialization
      GLFWwindow* window;
  
      if (!glfwInit()) {
          return -1;
      }
  
      window = glfwCreateWindow(640, 480, "Debugtest", NULL, NULL);
      if (!window) {
          glfwTerminate();
          return -1;
      }
  
      glfwMakeContextCurrent(window);
      glewInit();
  
      // Output the opengl version
      std::cout &lt;&lt; glGetString(GL_VERSION) &lt;&lt; std::endl;
  
      // Enable debug output
      glEnable(GL_DEBUG_OUTPUT);
      glDebugMessageCallback(MessageCallback, 0);
  
      unsigned int buffer;
      glGenBuffers(-1, &amp;buffer); // -1 throws an error according to http://docs.gl/gl4/glGenBuffers
  
      // Loop until the user closes the window
      while (!glfwWindowShouldClose(window)) {
          glfwPollEvents();
      };
  
      glfwTerminate();
      return 0;
  }
  </code></pre>
  
  <p>The code for the callback is from <a href="https://www.khronos.org/opengl/wiki/Debug_Output" rel="nofollow noreferrer">the khronos documentation</a>. <code>glGenBuffers</code> should throw an error acccording to <a href="http://docs.gl/gl4/glDebugMessageCallback" rel="nofollow noreferrer">the docs</a>. However, the OpenGL window stays white, the terminal just displays the OpenGL version (<code>4.5.13474 Copatibility Profile Context 22.19.162.4</code>).</p>
  
  <p>What is the best way to handle errors? How do I fix my code?</p>