O'Reilly logo

Mastering SFML Game Development by Raimondas Pupius

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Drawing with vertex indices

One last thing that is quite important for us before moving on is covering a more efficient way of rendering shapes. Our current method is fine for rendering a single triangle, but it can get inefficient really quickly when rendering something more complex, like a cube. If we are using vertices only, it would require a grand total of 36 to render six cube faces. A much more efficient approach would obviously be submitting eight vertices for each corner of the cube and then reusing them to draw each face. Luckily, there is a way to do just that by using an index array.

Using indices simply means that for each model we are drawing, we also need to store an array of indices that represent the draw order of vertices. Each ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required