title: OpenGL buffer woes
body: <p>I've been getting back into OpenGL recently after transitioning to linux. For some reason or another, things like <code>glGenBuffers</code>, <code>glBindBuffer</code>, etc, aren't present with the normal GL headers, and cause my program to crash using GLEW. To get around this I've been using GLES2.</p>
  
  <p>And now the problem:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;SFML/Graphics.hpp&gt;
  #include &lt;GLES2/gl2.h&gt;
  #include &lt;GL/gl.h&gt;
  
  int main() {
    sf::RenderWindow window(sf::VideoMode(640, 480), "OpenGL Tests");
  
    glOrtho(0, 640, 0, 480, -1, 1);
    glEnable(GL_TEXTURE_2D);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_BLEND);
    glClearColor(0, 0, 0, 0);
  
    //x, y, r, g, b
    GLfloat triangleVertices[15] = {
      10, 10, 1, 0, 0,
      110, 10, 0, 1, 0,
      60, 96.6f, 0, 0, 1
    };
    GLuint triangleBuf;
  
    glGenBuffers(1, &amp;triangleBuf);
    glBindBuffer(GL_VERTEX_ARRAY, triangleBuf);
    glBufferData(GL_VERTEX_ARRAY, sizeof(triangleVertices), triangleVertices, GL_STATIC_DRAW);
    glBindBuffer(GL_VERTEX_ARRAY, 0);
  
    while(window.isOpen()) {
      sf::Event event;
  
      while(window.pollEvent(event)) {
        if(event.type == sf::Event::Closed) window.close();
      }
  
      glClear(GL_COLOR_BUFFER_BIT);
  
      glBindBuffer(GL_VERTEX_ARRAY, triangleBuf);
      glEnableClientState(GL_VERTEX_ARRAY);
      glVertexPointer(2, GL_FLOAT, 3, 0);
      glEnableClientState(GL_COLOR_ARRAY);
      glColorPointer(3, GL_FLOAT, 2, (GLfloat*) 2);
      glDrawArrays(GL_TRIANGLES, 0, 3);
  
      window.display();
      sf::sleep(sf::milliseconds(50));
    }
  
    glDeleteBuffers(1, &amp;triangleBuf);
  }
  </code></pre>
  
  <p>This is how I remember using buffers, though to be honest I don't trust my memory. With good reason it seems, since this crashes immediately after the window opens.</p>
  
  <p>I've tried changing the last argument to <code>glDrawArrays</code> to 1 instead of 3. I've also tried binding the buffer twice, first as <code>GL_VERTEX_ARRAY</code>, followed by <code>glVertexPointer</code>, second as <code>GL_COLOR_ARRAY</code>, followed by <code>glColorPointer</code>. No dice.</p>