The call glDrawElements(..., indices.size(), GL_UNSIGNED_SHORT, 0);
tells your GPU roughly following:
for(unsigned short i = 0 /*last parameter*/; i < indices.size(); i += 3 /*3 vertices/triangle*/ )
{
drawTriangle(VBO[indices[i]], VBO[indices[i + 1]], VBO[indices[i + 2]] );
}
Do you see what is wrong now? You need index for each vertex drawn. In you draw method you told GPU to renderIf the value of indices.size()indices[i]
(which happends to be 6) vertices. Additionally, there might be one more error in specifying is higher than your size/leght in some other glCall(I would expect last 2 triangles drawn) of VBO, it is a problem.
A somebody gave me a good advice: when everything fails, start drawing. I dont say this is copy/paste solutionMoreover, but hopefullyfor VBO it gives you an idea how to solve similar problems, taking pencil and paper and getting right indices manually gives:
![enter image description here][1]
...it should not be difficult to derive right formulais (you probably already have the right one, just you needrecommended to apply if for every "index" = for every quad and handle looping from backhave around 1-4MB of quad "strip")
[1]:vertices in it https://i.sstatic.net/n9QZY.png- only 4 vertices/VBO will very likely kill your performance.
big edit reason: cant read right(solved in comments)