title: How to use VAOs in OpenGL ES 2.0
body: <p>I've read that using VAOs is recommended but I don't know how.
  I am using the tegra android development pack (which uses OpenGL ES 2.0) and I can't find the methodes glGenVertexArrays and glBindVertexArray. Are VAOs supported in ES 2.0 (without extensions)?</p>
  
  <p>Also I don't understand what the benefit of a VAO is. Currently I compile the shaders and use glBindAttribLocation. After that I define the vertex positions and colors for a triangle and use glVertexAttribPointer. Then I just draw the triangle again and again.</p>
  
  <p>This is the program (without error checks):</p>
  
  <pre><code>static void createProgram() {
      // vertex shader
      const char* vertexShaderCode = getVertexShaderCode();
      GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
      glShaderSource(vertexShader, 1, &amp;vertexShaderCode, NULL);
      glCompileShader(vertexShader);
  
      // fragment shader
      const char* fragmentShaderCode = getFragmentShaderCode();
      GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
      glShaderSource(fragmentShader, 1, &amp;fragmentShaderCode, NULL);
      glCompileShader(fragmentShader);
  
      // create program
      program = glCreateProgram();
      glAttachShader(program, vertexShader);
      glAttachShader(program, fragmentShader);
  
      // Dem Programm sagen, unter welchem Index die Daten der Shader Attribute liegen
      glBindAttribLocation(program, 1, "in_pos");
      glBindAttribLocation(program, 2, "in_color");
  
      glLinkProgram(program);
  }
  </code></pre>
  
  <p>And this is the triangle:</p>
  
  <pre><code>static void loadGeometry() {
      GLuint buffers[2];
      glGenBuffers(2, buffers);
      GLuint vboPosition = buffers[0];
      GLuint vboColor = buffers[1];
  
      const int VERTEX_POSITION_BUFFER_SIZE = 12;
      const int VERTEX_POSITION_BUFFER_BYTESIZE = sizeof(GLfloat)* VERTEX_POSITION_BUFFER_SIZE;
  
      GLfloat vertexPositionBuffer[VERTEX_POSITION_BUFFER_SIZE] = {
          0.0f, 0.5f, 0.0f, 1.0f,
          -0.5f, -0.5f, 0.0f, 1.0f,
          0.5f, -0.5f, 0.0f, 1.0f };
  
      glBindBuffer(GL_ARRAY_BUFFER, vboPosition);
      glBufferData(GL_ARRAY_BUFFER, VERTEX_POSITION_BUFFER_BYTESIZE, vertexPositionBuffer, GL_STATIC_DRAW);
      glEnableVertexAttribArray(1);
      glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, 0);
  
      // Repeat for color...
  }
  </code></pre>
  
  <p>And in the draw call I just do</p>
  
  <pre><code>glUseProgram(program);
  glDrawArrays(GL_TRIANGLES, 0, 3);
  </code></pre>