title: OpenGL window isn't opening
body: <p>I have code from the OpenGLBook (openglbook.com) which compiles, but does not load. I have absolutely no idea why it's not loading. The code is as follows:</p>
  
  <p><strong>main.cpp</strong></p>
  
  <pre><code>#include "main.h"
  
  /// Methods
  /// -----------------------------
  
  int main(int argc, char* argv[])
  {
      Initialize(argc, argv);
  
      glutMainLoop();
  
      exit(EXIT_SUCCESS);
  }
  </code></pre>
  
  <p><strong>main.h</strong></p>
  
  <pre><code>#ifndef main_h
  #define main_h
  
  #include &lt;cstdlib&gt;
  #include &lt;cstdio&gt;
  #include &lt;cstring&gt;
  #include &lt;GL/glew.h&gt;
  #include &lt;GL/freeglut.h&gt;
  
  #define WINDOW_TITLE_PREFIX "CHAPTER 1"
  
  void Initialize(int, char*[]);
  void InitWindow(int, char*[]);
  void ResizeFunction(int, int);
  void RenderFunction(void);
  
  #endif
  </code></pre>
  
  <p><strong>functions.cpp</strong></p>
  
  <pre><code>#include "main.h"
  
  int CurrentWidth = 800,
      CurrentHeight = 600,
      WindowHandle = 0;
  
  void Initialize(int argc, char* argv[])
  {
      InitWindow(argc, argv);
  
      fprintf(
          stdout,
          "INFO: OpenGL Version: %s\n",
          glGetString(GL_VERSION)
          );
  
      glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
  }
  
  void InitWindow(int argc, char* argv[])
  {
      glutInit(&amp;argc, argv);
  
      glutInitContextVersion(4, 2);
      glutInitContextFlags(GLUT_FORWARD_COMPATIBLE);
      glutInitContextProfile(GLUT_CORE_PROFILE);&lt;/pre&gt;
  
      glutSetOption(
          GLUT_ACTION_ON_WINDOW_CLOSE,
          GLUT_ACTION_GLUTMAINLOOP_RETURNS
          );
  
      glutInitWindowSize(CurrentWidth, CurrentHeight);
  
      glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
  
      WindowHandle = glutCreateWindow(WINDOW_TITLE_PREFIX);
  
      if(WindowHandle &lt; 1) {
          fprintf(
              stderr,
              "ERROR: Could not create a new rendering window.\n"
              );
          exit(EXIT_FAILURE);
      }
  
      glutReshapeFunc(ResizeFunction);
      glutDisplayFunc(RenderFunction);
  
  }
  
  void ResizeFunction(int Width, int Height)
  {
      CurrentWidth = Width;
      CurrentHeight = Height;
      glViewport(0, 0, CurrentWidth, CurrentHeight);
  }
  
  void RenderFunction(void)
  {
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  
      glutSwapBuffers();
      glutPostRedisplay();
  }
  </code></pre>
  
  <p>When I compile and try to run my .exe with Visual Studio 2010, nothing happens at all.
  The OpenGL window doesn't even open. Visual Studio acts as if it is running something for about 2 seconds, then returns to its normal state.</p>