title: Can a VBO be bound to multiple VAOs?
body: <p>I'm trying to render a model's UV map by treating its texture coordinates as an array of vertex positions. I set up a VAO for the model which renders perfectly, then tried adding a second VAO and binding the texture coordinate buffer to it. Unfortunately it doesn't render anything.</p>
  
  <p>I've written a second set of vertex and fragment shaders for the UV map which compile just fine. The buffer is bound in the same way as with the model VAO and the vertex attributes set. The only difference I can see is I'm not re-specifying the buffer data.</p>
  
  <p>This is my code for setting up the model VAO:</p>
  
  <pre><code>// Create model VAO
  
  glGenVertexArrays( 1, &amp;modelVAO );
  glBindVertexArray( modelVAO );
  
  // Create position buffer
  
  glGenBuffers( 1, &amp;positionBuffer );
  glBindBuffer( GL_ARRAY_BUFFER, positionBuffer );
  glBufferData( GL_ARRAY_BUFFER, sizeof( GLfloat ) * vertexCount * 4, positions, GL_STATIC_DRAW );
  glVertexAttribPointer( 0, 4, GL_FLOAT, GL_FALSE, 0, 0 );
  glEnableVertexAttribArray( 0 );
  
  // Create normal buffer
  
  glGenBuffers( 1, &amp;normalBuffer );
  glBindBuffer( GL_ARRAY_BUFFER, normalBuffer );
  glBufferData( GL_ARRAY_BUFFER, sizeof( GLfloat ) * vertexCount * 3, normals, GL_STATIC_DRAW );
  glVertexAttribPointer( 1, 3, GL_FLOAT, GL_FALSE, 0, 0 );
  glEnableVertexAttribArray( 1 );
  
  // Create texture coordinate buffer
  
  glGenBuffers( 1, &amp;textureCoordinateBuffer );
  glBindBuffer( GL_ARRAY_BUFFER, textureCoordinateBuffer );
  glBufferData( GL_ARRAY_BUFFER, sizeof( GLfloat ) * vertexCount * 2, textureCoordinates, GL_DYNAMIC_DRAW );
  glVertexAttribPointer( 2, 2, GL_FLOAT, GL_FALSE, 0, 0 );
  glEnableVertexAttribArray( 2 );
  
  // Unbind model VAO
  
  glBindVertexArray( 0 );
  </code></pre>
  
  <p>Then I set up the UV map VAO like this:</p>
  
  <pre><code>// Create new UV map VAO
  
  glGenVertexArrays( 1, &amp;uvMapVAO );
  glBindVertexArray( uvMapVAO );
  
  // Bind texture coordinate buffer
  
  glBindBuffer( GL_ARRAY_BUFFER, textureCoordinateBuffer );
  glVertexAttribPointer( 0, 2, GL_FLOAT, GL_FALSE, 0, 0 );
  glEnableVertexAttribArray( 0 );
  
  // Unbind UV map VAO
  
  glBindVertexArray( 0 );
  </code></pre>
  
  <p>Is it possible to use the same VBO with more than one VAO like this?</p>