tags:

views:

31

answers:

0

I can't figure out how to get glDrawElements to not connect everything it draws...

//Draw Reds
 glEnableVertexAttribArray(vLoc);
 glEnableVertexAttribArray(cLoc);

 glBindBuffer(GL_ARRAY_BUFFER,positionBufferRed);
 glVertexAttribPointer(vLoc,3,GL_FLOAT,GL_FALSE,0,0);

 glBindBuffer(GL_ARRAY_BUFFER,redBuffer);
 glVertexAttribPointer(cLoc,3,GL_FLOAT,GL_FALSE,0,0);

 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,elementBufferRed);
 glDrawElements(GL_TRIANGLES,nElements*3,GL_UNSIGNED_INT,0);

 glDisableVertexAttribArray(vLoc);
 glDisableVertexAttribArray(cLoc);


 //Draw Blues
 glEnableVertexAttribArray(vLoc);
 glEnableVertexAttribArray(cLoc);

 glBindBuffer(GL_ARRAY_BUFFER,positionBufferBlue);
 glVertexAttribPointer(vLoc,3,GL_FLOAT,GL_FALSE,0,0);

 glBindBuffer(GL_ARRAY_BUFFER,blueBuffer);
 glVertexAttribPointer(cLoc,3,GL_FLOAT,GL_FALSE,0,0);

 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,elementBufferBlue);
 glDrawElements(GL_TRIANGLES,nElements*3,GL_UNSIGNED_INT,0);

 glDisableVertexAttribArray(vLoc);
 glDisableVertexAttribArray(cLoc);

This is what the result looks like: http://img338.imageshack.us/img338/2440/cows.png

Should be two separate cows but instead they're connected with black lines. Any advice will be appreciated!