Can we add a start offset value to glDrawElements

This is the draw call for glDrawElements

glDrawElements(GL_TRIANGLES, indicesTaperRectangle.size(), GL_UNSIGNED_INT, 0);

can i add the start offset value like it should start from the 3rd index value ?

>Solution :

When a named buffer object is bound to the GL_ELEMENT_ARRAY_BUFFER target, the last argument of glDrawElements is treated as a byte offset as a byte offset into the buffer object’s data store:

auto offset = sizeof(unsigned int) * 3;
glDrawElements(
    GL_TRIANGLES,
    indicesTaperRectangle.size() - 3, 
    GL_UNSIGNED_INT, 
    (const void*)offset);

Leave a Reply