Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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 ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading