title: OpenGL nvoglv32.dll error
body: <p>My program compiles fine but when I run it, it crashes at glDrawArrays(GL_TRIANGLE_STRIP, 0, 4) saying:</p>
  
  <pre><code>Unhandled exception at 0x50D6C94E (nvoglv32.dll) in Chapter 2.exe: 0xC0000005: Access violation reading location 0x00000000.
  </code></pre>
  
  <p>A page also appears that says nvoglv32.pdb is not loaded. I checked to see if the pointers and values I passed were correct, and assert did not pick up anything.</p>
  
  <p>Here's the code</p>
  
  <p>Example.h</p>
  
  <pre><code>#include &lt;windows.h&gt;
  #include "Example.h"
  #include &lt;iostream&gt;
  #include &lt;gl\GLU.h&gt;
  #include &lt;gl\glext.h&gt;
  #include "BufferUtilities.h"
  
  bool Example::init()
  {
      if (!start())
      {
          return false;
      }
  
      glEnable(GL_DEPTH_TEST);
      glClearColor(0.5f, 0.5f, 0.5f, 0.5f);
  
      GLfloat verticies[] = {
          -2.0f, -2.0f, -2.0f,
          2.0f, -2.0f, -2.0f,
          -2.0f, -2.0f, 2.0f,
          2.0f, -2.0f, 2.0f,
      };
  
      GLfloat colors[] = {
          1.0f, 0.0f, 0.0f,
          0.0f, 1.0f, 0.0f,
          0.0f, 0.0f, 1.0f,
          1.0f, 1.0f, 0.0f,
      };
  
      createArrayBuffer(verticies, &amp;vertexBuffer, GL_STATIC_DRAW);
      createArrayBuffer(colors, &amp;colorBuffer, GL_STATIC_DRAW);
  
      glEnableClientState(GL_COLOR_ARRAY);
      glEnableClientState(GL_VERTEX_ARRAY);
  
      return true;
  }
  
  void Example::render()
  {
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
      glLoadIdentity();
  
      bindAndPoint(&amp;colorBuffer, 3);
  
      bindAndPoint(&amp;vertexBuffer, 3);
  
      glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
  }
  </code></pre>
  
  <p>BufferUtilities.h</p>
  
  <pre><code>#pragma once
  
  #include &lt;Windows.h&gt;
  #include &lt;gl\GL.h&gt;
  #include &lt;gl\GLU.h&gt;
  #include &lt;gl\GLEXT.h&gt;
  #include &lt;gl\wglext.h&gt;
  #include &lt;iostream&gt;
  #include &lt;assert.h&gt;
  
  #define BUFFER_OFFSET(i) ((char *)NULL+(i))
  
  static PFNGLGENBUFFERSARBPROC glGenBuffers = NULL;
  static PFNGLBINDBUFFERPROC glBindBuffer = NULL;
  static PFNGLBUFFERDATAPROC glBufferData = NULL;
  
  inline bool start()
  {
      glGenBuffers = (PFNGLGENBUFFERSARBPROC)wglGetProcAddress("glGenBuffers");
      glBindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBuffer");
      glBufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferData");  
  
      if (!glGenBuffers|| !glBindBuffer || !glBufferData)
      {
          std::cerr &lt;&lt; "Vertex buffer objects are not supported by your graphics card." &lt;&lt; std::endl;
          return false;
      }
  
      return true;
  }
  
  inline void createArrayBuffer(GLfloat *array, GLuint *buffer, GLenum usage)
  {
      assert(array != NULL);
      assert(buffer != NULL);
      assert(usage != NULL);
  
      glGenBuffers(1, buffer);
      glBindBuffer(GL_ARRAY_BUFFER, *buffer);
      glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * (sizeof(array) / sizeof(array[0])), &amp;array[0], usage);
  }
  
  inline void bindAndPoint(GLuint *buffer, int size)
  {
      assert(buffer != NULL);
      assert(size != NULL);
  
      glBindBuffer(GL_ARRAY_BUFFER, *buffer);
      glColorPointer(size, GL_FLOAT, 0, BUFFER_OFFSET(0));
  }
  </code></pre>