home | login | register | DMCA | contacts | help | donate |      

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
А Б В Г Д Е Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Э Ю Я


my bookshelf | genres | recommend | rating of books | rating of authors | reviews | new | форум | collections | читалки | авторам | add
fantasy
space fantasy
fantasy is horrors
heroic
prose
  military
  child
  russian
detective
  action
  child
  ironical
  historical
  political
western
adventure
adventure (child)
child's stories
love
religion
antique
Scientific literature
biography
business
home pets
animals
art
history
computers
linguistics
mathematics
religion
home_garden
sport
technique
publicism
philosophy
chemistry
close

Loading...


What is an Index Buffer?

An index buffer is a memory buffer that holds indices that "point" to vertices in your vertex buffer. When a scene is rendered, DirectX performs certain calculations on each vertex such as lighting and transformations. What we want to do is minimise the amount of calculations that DirectX has to do, therefore, we need to minimise the number of vertices. We can do this using an index buffer. Lets say you want to draw a square. Your square will be made up from two triangles, which is six vertices (using a triangle list). But we only really need four vertices to define a square (one for each corner). We had to use six vertices because two of them are shared (have the same value). Because we have shared vertices, it's a good idea to use an index buffer. Here's how it works: we define the four corners of our square as vertices in our vertex buffer. Then we define six indices in our index buffer each of which "point" to a vertex in the vertex buffer. We then render our triangles from the indices in the index buffer and so, only use four vertices. Fig 8.1 below shows this example.

DirectX 8 Programming Tutorial

Fig 8.1

In the example above, we have only used four vertices to describe our square, which is a saving of two vertices. The index buffer contains six elements, each of these elements contains an index to a vertex in the vertex buffer. Notice that the order in the index buffer is in a clockwise direction, this is the order in which vertices will be rendered. We then render our scene as before, except this time we use the index buffer in addition to our vertex buffer. So, if we apply this technique to our cube, we will be saving twelve vertices (24 rather than 36). That doesn't sound that much does it? But imagine a scene that contains 100 cubes, that's a saving of 1200 vertex calculations per frame!


Introduction | DirectX 8 Programming Tutorial | Implementing an Index Buffer in DirectX







Loading...