title: OpenGL Superbible first program crashes
body: <p>It doesn't run, obviously. Code is copied directly from the provided source. I put the libraries and headers where I was told. Running it results in some sort of crash.</p>
  
  <p>I asked a few people to run it, they all said that it gave them an error concerning missing .dlls and didn't attempt to run the program, completely different from what's happening to me.</p>
  
  <p>from the "x.exe has stopped working" dialog:</p>
  
  <pre><code>Problem signature:
    Problem Event Name:   BEX
    Application Name: OpenGLtutorialCh2.exe
    Application Version:  0.0.0.0
    Application Timestamp:    4d02d634
    Fault Module Name:    StackHash_0a9e
    Fault Module Version: 0.0.0.0
    Fault Module Timestamp:   00000000
    Exception Offset: 00000000
    Exception Code:   c0000005
    Exception Data:   00000008
    OS Version:   6.1.7600.2.0.0.256.48
    Locale ID:    1033
    Additional Information 1: 0a9e
    Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
    Additional Information 3: 0a9e
    Additional Information 4: 0a9e372d3b4ad19135b953a78882e789
  </code></pre>
  
  <p>Build:</p>
  
  <pre><code>    1&gt;------ Rebuild All started: Project: OpenGLtutorialCh2, Configuration: Debug Win32 ------
  1&gt;  triangle.cpp
  1&gt;LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
  1&gt;gltools.lib(GLBatch.obj) : warning LNK4099: PDB 'vc90.pdb' was not found with 'gltools.lib(GLBatch.obj)' or at 'C:\Users\Bacu\documents\visual studio 2010\Projects\OpenGLtutorialCh2\Debug\vc90.pdb'; linking object as if no debug info
  1&gt;gltools.lib(glew.obj) : warning LNK4099: PDB 'vc90.pdb' was not found with 'gltools.lib(glew.obj)' or at 'C:\Users\Bacu\documents\visual studio 2010\Projects\OpenGLtutorialCh2\Debug\vc90.pdb'; linking object as if no debug info
  1&gt;gltools.lib(GLShaderManager.obj) : warning LNK4099: PDB 'vc90.pdb' was not found with 'gltools.lib(GLShaderManager.obj)' or at 'C:\Users\Bacu\documents\visual studio 2010\Projects\OpenGLtutorialCh2\Debug\vc90.pdb'; linking object as if no debug info
  1&gt;gltools.lib(GLTools.obj) : warning LNK4099: PDB 'vc90.pdb' was not found with 'gltools.lib(GLTools.obj)' or at 'C:\Users\Bacu\documents\visual studio 2010\Projects\OpenGLtutorialCh2\Debug\vc90.pdb'; linking object as if no debug info
  1&gt;gltools.lib(GLTriangleBatch.obj) : warning LNK4099: PDB 'vc90.pdb' was not found with 'gltools.lib(GLTriangleBatch.obj)' or at 'C:\Users\Bacu\documents\visual studio 2010\Projects\OpenGLtutorialCh2\Debug\vc90.pdb'; linking object as if no debug info
  1&gt;LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
  1&gt;gltools.lib(GLBatch.obj) : warning LNK4099: PDB 'vc90.pdb' was not found with 'gltools.lib(GLBatch.obj)' or at 'C:\Users\Bacu\documents\visual studio 2010\Projects\OpenGLtutorialCh2\Debug\vc90.pdb'; linking object as if no debug info
  1&gt;gltools.lib(glew.obj) : warning LNK4099: PDB 'vc90.pdb' was not found with 'gltools.lib(glew.obj)' or at 'C:\Users\Bacu\documents\visual studio 2010\Projects\OpenGLtutorialCh2\Debug\vc90.pdb'; linking object as if no debug info
  1&gt;gltools.lib(GLShaderManager.obj) : warning LNK4099: PDB 'vc90.pdb' was not found with 'gltools.lib(GLShaderManager.obj)' or at 'C:\Users\Bacu\documents\visual studio 2010\Projects\OpenGLtutorialCh2\Debug\vc90.pdb'; linking object as if no debug info
  1&gt;gltools.lib(GLTools.obj) : warning LNK4099: PDB 'vc90.pdb' was not found with 'gltools.lib(GLTools.obj)' or at 'C:\Users\Bacu\documents\visual studio 2010\Projects\OpenGLtutorialCh2\Debug\vc90.pdb'; linking object as if no debug info
  1&gt;gltools.lib(GLTriangleBatch.obj) : warning LNK4099: PDB 'vc90.pdb' was not found with 'gltools.lib(GLTriangleBatch.obj)' or at 'C:\Users\Bacu\documents\visual studio 2010\Projects\OpenGLtutorialCh2\Debug\vc90.pdb'; linking object as if no debug info
  1&gt;  OpenGLtutorialCh2.vcxproj -&gt; C:\Users\Bacu\documents\visual studio 2010\Projects\OpenGLtutorialCh2\Debug\OpenGLtutorialCh2.exe
  ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
  </code></pre>
  
  <p>Code in question:</p>
  
  <pre><code>    #include &lt;GLTools.h&gt;
  #include &lt;GLShaderManager.h&gt;
  
  #ifdef __APPLE__
  #include &lt;glut/glut.h&gt;
  #else
  #define FREEGLUT_STATIC
  #include &lt;GL/glut.h&gt;
  #endif
  
  GLBatch triangleBatch;
  GLShaderManager shaderManager;
  
  
  ///////////////////////////////////////////////////////////////////////////////
  // Window has changed size, or has just been created. In either case, we need
  // to use the window dimensions to set the viewport and the projection matrix.
  void ChangeSize(int w, int h)
  {
      glViewport(0,0,w,h);
  }
  
  ///////////////////////////////////////////////////////////////////////////////
  // This function does any needed initialization on the rendering context.
  // This is the first opportunity to do any OpenGL related tasks.
  void SetupRC()
  {
      glClearColor(0.0f,0.0f,1.0f,1.0f);
  
      shaderManager.InitializeStockShaders();
  
      GLfloat vVerts[]= {
          -0.5f,  0.0f,   0.0f,
          0.5f,   0.0f,   0.0f,
          0.0f,   0.5f,   0.0f };
  
      triangleBatch.Begin(GL_TRIANGLES, 3);
      triangleBatch.CopyVertexData3f(vVerts);
      triangleBatch.End();
  }
  
  ///////////////////////////////////////////////////////////////////////////////
  // Called to draw scene
  void RenderScene(void)
  {
      // Clear the window with current clearing color
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
  
      GLfloat vRed[] = {1.0f, 0.0f, 0.0f, 1.0f};
      shaderManager.UseStockShader(GLT_SHADER_IDENTITY, vRed);
      triangleBatch.Draw();
      glutSwapBuffers();
  }
  
  ///////////////////////////////////////////////////////////////////////////////
  // Main entry point for GLUT based programs
  int main(int argc, char* argv[])
  {
      gltSetWorkingDirectory(argv[0]);
  
      glutInit(&amp;argc, argv);
      glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL);
      glutInitWindowSize(800,600);
      glutCreateWindow("Triangle");
      glutReshapeFunc(ChangeSize);
      glutDisplayFunc(RenderScene);
  
      GLenum err = glewInit();
      if (GLEW_OK != err) {
          fprintf(stderr, "GLEW ERROR: %s\n", glewGetErrorString(err));
          return 1;
      }
  
      SetupRC();
      glutMainLoop();
      return 0;
  }
  </code></pre>
  
  <hr>
  
  <p>I asked a few people to run it, they all said that it gave them an error concerning missing .dlls and didn't attempt to run the program, completely different from what's happening to me.</p>