PDA

View Full Version : Vertex Buffer and Index Buffer



iris_raj
01-14-2007, 08:18 PM
Dear All,
What is difference between Vertex Buffer and Index Buffer.In which they are used.

RAJESH.R

Zengar
01-15-2007, 12:15 AM
Veretx buffer is used to store vertex arrays (used with DrawArrays, DrawElements functions), index buffer is used to store indices that index vertices when rendering via DrawElements function (refer to API description for explanation).

k_szczech
01-15-2007, 01:24 AM
Vertex buffer stores vertex coordinates.
Index buffer stores indices.
If you connect vertices stored in vertex buffer in order defined by index array you'll get proper primitives rendered.
For example:

(-1,1) (1, 1)
.-----.
| /|
| / |
| / |
| / |
|/ |
.-----.
(-1,-1) (1, -1)

Vertex array:
-1,1, 1,1, 1,-1, -1,-1
Index array:
0, 1, 3, 1, 2, 3If you render GL_TRIANGLES using this index array and vertex array you'll get these two triangles rendered.