title: Open GL - ES 2.0 : Multiple Vertex Buffer Object
body: <p>I had a quick question on openGL ES 2.0 I am trying to create some drawings on the screen which will require multiple geometries. This is how I am creating the geometries.</p>
  
  <pre><code>(void)setupBoxGeometry{
  
     GLuint vertexBuffer;
     glGenBuffers(1, &amp;vertexBuffer);
     glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
     glBufferData(GL_ARRAY_BUFFER, sizeof(BoxVertices), BoxVertices, GL_STATIC_DRAW);
  
     GLuint indexBuffer;
     glGenBuffers(1, &amp;indexBuffer);
     glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
     glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(BoxIndices), BoxIndices, GL_STATIC_DRAW);
  }
  
  - (void)setupLineGeometry{
  
     GLuint vertexBuffer;
     glGenBuffers(1, &amp;vertexBuffer);
     glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
     glBufferData(GL_ARRAY_BUFFER, sizeof(LineVertices), LineVertices, GL_STATIC_DRAW);
  
     GLuint indexBuffer;
     glGenBuffers(1, &amp;indexBuffer);
     glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
     glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(LineIndices), LineIndices, GL_STATIC_DRAW);
  }
  </code></pre>
  
  <p>This is my render function</p>
  
  <pre><code>- (void)render:(CADisplayLink*)displayLink {
     glClearColor(0.0/255.0, 0.0/255.0, 0.0/255.0, 1.0);
     glClear(GL_COLOR_BUFFER_BIT);
  
     float h = 4.0f * self.frame.size.height / self.frame.size.width;
     glViewport(0, 0, self.frame.size.width, self.frame.size.height);
  
     glVertexAttribPointer(_positionSlot, 3, GL_FLOAT, GL_FALSE, 
                        sizeof(Vertex), 0);
     glVertexAttribPointer(_colorSlot, 4, GL_FLOAT, GL_FALSE, 
                        sizeof(Vertex), (GLvoid*) (sizeof(float) * 3));
  
  
     // Do some thing to the projection    
     CC3GLMatrix *projection = [CC3GLMatrix matrix];    
     [projection populateFromFrustumLeft:-2 andRight:2 andBottom:-h/2 andTop:h/2 andNear:4 andFar:10];
     glUniformMatrix4fv(_projectionUniform, 1, 0, projection.glMatrix);
  
  
     // Create the base for the square to be drawn on the screen    
     _baseMatrix = [CC3GLMatrix matrix];
  
  
     [_baseMatrix populateFromTranslation:CC3VectorMake(-3.0, -5.2 + _yIncrease, -10)];    
     [_baseMatrix scaleByX:0.5];
     [_baseMatrix scaleByY:_yIncrease];
     [_baseMatrix rotateBy:CC3VectorMake(0, _rotationAngle, 0)];
     glUniformMatrix4fv(_modelViewUniform, 1, 0, _baseMatrix.glMatrix);
     glDrawElements(GL_TRIANGLES, sizeof(BoxIndices)/sizeof(BoxIndices[0]), 
                 GL_UNSIGNED_BYTE, 0);
  }
  </code></pre>
  
  <p>I call the box geometry function before I call the line geometry function. The problem is now my render function only draws lines. It does not draw any boxes. What am I doing wrong. If the question is not clear I can give more clarifications/</p>