I’m extending the Xcode opengles template, got rid of the virtual es1 stuff.
Now I managed to render my model from RAM both vertexArray and indexArray,
then I managed to gen-,bind-,dataBuffer the vertexArray VBO and changed the regular RAM-pointers to offset-pointers.
This all works fine, however the next phase to place the indexAray in a BO and gen-,bind-,dataBuffer and change the RAM-pointers to offset-pointers fails 🙁
Are there any common pitfalls I haven’t notice, to me anyone able to make a VBO should be able to make an indexArray-buffer…
The following code is done in the setupGL
glGenBuffers(1, &geometryPtr->vertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, geometryPtr->vertexBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(geometryPtr->vertexNormalUV), geometryPtr->vertexNormalUV, GL_STATIC_DRAW);
//
glGenBuffers(1, &geometryPtr->vertexIndicesBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, geometryPtr->vertexIndicesBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(geometryPtr->indices), geometryPtr->indices, GL_STATIC_DRAW);
Then the basic idea in the render routine
glBindBuffer(GL_ARRAY_BUFFER, geometryPtr->vertexBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, geometryPtr->vertexIndicesBuffer);
glVertexAttribPointer(GLKVertexAttribPosition, 3, GL_FLOAT, GL_FALSE, 32, BUFFER_OFFSET(0));
glEnableVertexAttribArray(GLKVertexAttribPosition);
glVertexAttribPointer(GLKVertexAttribNormal, 3, GL_FLOAT, GL_FALSE, 32, BUFFER_OFFSET(12));
glEnableVertexAttribArray(GLKVertexAttribNormal);
glVertexAttribPointer(GLKVertexAttribTexCoord0, 2, GL_FLOAT, GL_TRUE, 32, BUFFER_OFFSET(24));
glEnableVertexAttribArray(GLKVertexAttribTexCoord0);
//
glDrawElements(GL_TRIANGLES, trianglesCount*3, GL_UNSIGNED_SHORT, (void *)offset);
glDrawElements(GL_TRIANGLE_STRIP, triangleStripOffsets[m], GL_UNSIGNED_SHORT, (void *)offset);
Please help? 🙂
Niels
I’ve answered the question in the comments, following the suggestion of Mr. Larson I will supply an (official) answer to close the question.
To elude further, I basically assumed sizeof() would make the system ask the system-memory-manager to ask the size, assigned to the pointer send…
Niels
Ps.
Thanks Mr. Larson.