Creating Vertex and Index Buffer Objects

To load in the height map, we’re going to use two new OpenGL objects: a vertex buffer object and an index buffer object. These two objects are analogous to the vertex arrays and index arrays that we’ve been using in previous chapters, except that the graphics driver can choose to place them directly in the GPU’s memory. This can lead to better performance for objects that we don’t change often once they’ve been created, such as a height map. These buffer objects aren’t always faster, though, so it does pay to compare both options.

Creating a Vertex Buffer Object

To load in these buffer objects, we’ll need to create some supporting code. Let’s create a new class called VertexBuffer in the com.particles.android.data ...

Get OpenGL ES 2 for Android now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.