When we are painting geometry in a video game, we can paint it two ways: Either using Vertex Buffer or painting Vertex Buffer plus Index Buffer. What does each of those structures do? The first one would be Vertex Buffer, a whole of vertexes, as its names says; and the Index Buffer is a whole of indexes. Imagine that: in the previous case, we wanted to paint, we had the XZ axis, with X and Z, in a coordinates system, so we have a vertex here, another one here and another one here. This will be the vertex A, this will be the vertex B, and this will be the vertex C. And we want to paint this triangle. Vertex A's geometrical position might be, in this case, 2,2,2,2,0, in X and Z. Vertex B might be 4,4,0. And vertex C might be 6,1,0. Well, this would be each one of the vertexes. Our Vertex Buffer would be the vertexes which compose this information. So our Vertex Buffer would be 2,2,0, which is the following vertex, the A vertex, 4,4,0, which is the B vertex, and 6,1,0, which would be C vertex. Well, if we wanted to paint an extra triangle, in example, using the B and C vertexes and a new vertex, using a list of triangles, we would need the D vertex's information, which might be 8,3.5,0. Our Vertex Buffer to paint those three vertexes, this new triangle, we would need the three first vertexes of the first triangle, and the three second vertexes of the first triangle, which would be C,B,D. So, the C vertex is, again, 6,1,0, the B vertex would be 4,4,0, and the D vertex would be 8,3.5,0. So, this would be our Vertex Buffer's structure. Define the vertexes list of our two triangles. In this case we need six vertexes as we are using a triangles list. If instead of doing this with a Vertex Buffer, we used Index Buffer, the example would change a bit. The structure with the Vertex Buffer and Index Buffer will variate respect to what we have previously seen. In our new case, now our Vertex Buffer, if we want to paint this information with Vertex Buffer Index Buffer, the following, our Vertix Buffer will be defined by the vertexes A,B,C,D in this case 2,2,0; 4,4,0;6,1,0; 8,3.5,0. And this will be our Vertex Buffer. And the Index Buffer will define the format in which triangles are painted. In my case, in the previous one, we said we would paint the first triangle with the vertexes A, B and C. So, the vertex A, B, C, would be the vertex zero, the index 0 of the Vertex Buffer, the index 1 and the index 2. And the second triangle is painted by the vertexes C, B and D. In our case it will be C in the vertex 2, B in the vertex 1 and D in the vertex 3. So, to paint the list of the triangles and painting the same geometrical figure we've previously made, through Vertex Buffer Index Buffer, we would paint it this way. The Renderable Vertex class. To see the Renderable Vertex class, we will open Visual Studio, and we will see how it is formed. We will go to the Renderable Vertex class. In the Renderable Vertex class we have a first class which will be a base class, which will have the methods Draw and drawIndexed. Those methods are implemented because they will be implemented in their derivative classes. And then we have the classes TemplatedRenderableVertexs, which will be a template class. So, depending on the vertex time, we will have a structure of Renderable Vertex through Vertex Buffer or through Vertex Buffer plus Index Buffer. Templated Renderable Vertex class only uses Vertex Buffer. Then, if we look below the code, we've got another class called TempletedRenderableIndexedVertexs which uses a Vertex Buffer and an Index Buffer. So, as I say, these classes are template. Let's go again to the first part, to TemplatedRenderableVertexs, which as we said is a template class. We see that we have, on one side, a structure, a variable member of the ID3D11 Buffer type which is an ID3D11 Vertex Buffer, and the topology we are going to find. The topology is what we said at the beginning, if that was a triangles list, a lines list, tripled triangles or triangles list. The TemplatedRenderableVertexs class receives the Device, the vertexes, which is a memory array, a memory Buffer and the number of vertexes this memory array contains. Kinds of primitives and number of primitives. In this case, if we are painting triangles, the number of triangles and if we are painting lines, the number of lines. What this builder does is, basically, creating a Vertex Buffer, based on the information it receives, with the number of bytes of the vertex size, or the number of vertexes it receives, and fills the Vertex Buffer information based on the information it receives by the vertexes array. And it creates, in the end, the Vertex Buffer, with the device's createBuffer method. This would be the building part. Inside the class destroyer we have the CHECKED_RELEASE which destroys Vertex Buffer's memory and, finally, we have the draw method. Draw method overwrites the base class draw method of the starter class, on which we receive the Device or the Device context in this case, the effect we are going to use, and the parameters. We are going to use the Shader parameters. So, to paint the geometry, it sets the Vertex Buffer, the kind of primitive establishes the vertex's input layout. The kind of vertex, its appearance, the information it contains, sets the VertexShader's Shader we are going to use, establishes the constants and the PixelShader, as well as the shader parameters we are going to use. And finally we call the draw method, painting the geometry we are going to paint. So, as this class is template, it will allow us to easily create classes based on this structure for different kinds of vertexes. Then we have a Macro, which is this class, called CRENDERABLE_VERTEX_CLASS_TYPE_CREATOR, and it will help us to create different kinds of classes based on the class I previously found, by simply introducing its class number and its topology. So, if you look carefully here, in these three lines in here, 94, 95 and 96, we create a class which will be called LinesListRenderableVertexs, introducing its list lines topology. Another class, which will be called TriangleListRenderableVertexs, by introducing the triangles list topology. And finally the third class, called TrianglesStripRenderableVertexs, introducing the tripled triangles topology. So with these three lines we have created three new classes. Similarly to what we just saw, we have the class RenderableIndexedVertex which adds the indexes information to the class we have previously seen. Previously, we had only used Vertex Buffer, but in this new class we will also create the Index Buffer. The class builder gets the Device, the vertexes, the number of vertexes inside this vertexes array, the indexes, and the number of indexes inside the indexes array. Again the kind of topology and the last parameter is the index format. Indexes can have two formats, which are 16bits indexes or 32bits indexes. So, this class, again, is template, so it doesn't depend on the kind of vertex, but it will search different classes setting off from this one, which depending on the kind of vertex will fit in it. The builder's first part is similar to the previous class' builder, where it is creating the Vertex Buffer. And the second part creates the Index Buffer. Fill again the type of Index Buffer structure, in this case, the size of the memory bytes this Index Buffer needs to take is the number of indexes multiplied by the size of the index format, in this case, if it is a 16bit format, it will be the size of a word, which is two bytes, or if it is a 32bit format it will be the size of a sinebit which is 4 bytes. And finally it calls createBuffer to create the Index Buffer. The destroyer will be similar to the previous class, where we delete the Vertex Buffer and the Index Buffer. And the drawIndexed is also very similar to the previous class' Render, adding the Index Buffer establishment to it. It sets the Vertex Buffer, it sets the Index Buffer, it sets the primitives topology, again the layout, the Shader, the parameters, the pixelShader, and finally it calls drawIndexed to paint our primitive through Vertex and Index Buffer. Again we have a Macro, in this case called CRENDERABLE_VERTEX_ CLASS_TYPE_CREATOR which will allow us to create different classes from the three parameters which you can see next and from the previous class, where if you look carefully, in the lines 178, 179, 180 and 181, we created four classes called TriangleListRenderableIndexed16Vertexs, TriangleListRenderableIndexed32Vertexs, TriangleStripRenderableIndexed16Vertexs and TriangleStripRenderableIndexed32Vertexs, easily, with just one of them for each line, telling the Macro the parameters the class will have, its topology and the index format. So we could easily create different classes with just a code line. This will be our Renderable Vertex. Thanks to Renderable Vertex, we will be able to paint different geometries or different geometrical formats.