title: OpenGL VBO not displaying
body: <p>I'm having trouble drawing with VBOs.  Using immediate mode, I can easily draw a cubic grid of points, but its quite slow.  I wanted to use a VBO to try and speed up the drawing.  I'm using SDL/glew.  My output is a single black point.  The same sdl / glew setup code worked for textured triangles, but didn't use a struct to store the data - I want a struct for caching purposes, so the vertex colour is close to the vertex position.</p>
  
  <p>to set up sdl / glew:</p>
  
  <pre><code>if (SDL_Init(SDL_INIT_VIDEO) &lt; 0) {
      lm-&gt;Log(LogManager::Error, "Video initialization failed: " + std::string(SDL_GetError()));
      return false;
  }
  
  const SDL_VideoInfo *videoInfo;
  videoInfo = SDL_GetVideoInfo();
  
  if (!videoInfo) {
      lm-&gt;Log(LogManager::Error, "Video query failed: " + std::string(SDL_GetError()));
      return false;
  }
  
  int videoFlags;
  videoFlags = SDL_OPENGL;
  videoFlags |= SDL_GL_DOUBLEBUFFER;
  videoFlags |= SDL_HWPALETTE;
  videoFlags |= SDL_RESIZABLE;
  videoFlags |= SDL_FULLSCREEN;
  
  if (videoInfo-&gt;hw_available) {
      videoFlags |= SDL_HWSURFACE;
  } else {
      videoFlags |= SDL_SWSURFACE;
  }
  
  if (videoInfo-&gt;blit_hw) {
      videoFlags |= SDL_HWACCEL;
  }
  
  SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 0);
  SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
  
  int scrWidth = 1280, scrHeight = 800;
  GLfloat aspectRatio = (GLfloat) scrWidth / (GLfloat) scrHeight;
  *surface = SDL_SetVideoMode(scrWidth, scrHeight, 32, videoFlags);
  
  if (!*surface) {
      lm-&gt;Log(LogManager::Error, "Video mode set failed: " + std::string(SDL_GetError()));
      return false;
  }
  
  glewInit();
  
  if (!glewIsSupported("GL_VERSION_2_0")) {
      lm-&gt;Log(LogManager::Error, "OpenGL 2.0 not available");
      return false;
  }
  
  glViewport(0, 0, (GLsizei) scrWidth, (GLsizei) scrHeight); // Set the viewport
  glMatrixMode(GL_PROJECTION); // Set the Matrix mode
  glLoadIdentity();
  gluPerspective(75, aspectRatio, 0.1, 100.0);
  glMatrixMode(GL_MODELVIEW);
  glPointSize(5);
  glEnable(GL_DEPTH_TEST);
  glEnable(GL_BLEND);
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  </code></pre>
  
  <p>make the VBO:</p>
  
  <pre><code>struct Vertex {
      GLfloat position[3];
      GLfloat colour[3];
  };
  ... // then in the init function
  verts = new Vertex[numVerts];
  ... // fill verts
  vboId = 0;
  glGenBuffers(1, &amp;vboId);
  glBindBuffer(GL_ARRAY_BUFFER, vboId);
  glBufferData(GL_ARRAY_BUFFER, sizeof (verts), &amp;verts[0], GL_STATIC_DRAW);
  
  glVertexPointer(3, GL_FLOAT, sizeof (Vertex), (GLvoid*) offsetof(Vertex, position));
  glColorPointer(3, GL_FLOAT, sizeof (Vertex), (GLvoid*) offsetof(Vertex, colour));
  delete [] verts;
  </code></pre>
  
  <p>to draw:</p>
  
  <pre><code>glEnableClientState(GL_COLOR_ARRAY);
  glEnableClientState(GL_VERTEX_ARRAY);
  
  glVertexPointer(3, GL_FLOAT, sizeof (Vertex), (GLvoid*) offsetof(Vertex, position));
  glColorPointer(3, GL_FLOAT, sizeof (Vertex), (GLvoid*) offsetof(Vertex, colour));
  
  glDrawArrays(GL_POINTS, 0, numVerts);
  
  glDisableClientState(GL_COLOR_ARRAY);
  glDisableClientState(GL_VERTEX_ARRAY);
  </code></pre>