Game Development Reference
In-Depth Information
The first value would be 0 , since the first triangle starts with the first vertex. The
secondvaluewouldbetheindexofthefirstvertexofthesecondtriangleinthevertex
buffer. This allows triangles to share vertices, as it is very common for two triangles
to have vertices that are at the same point in 3D space. Clearly, this wastes memory
if we re-define the same vertex more than once to create a separate instance of it
for each triangle that has that vertex in it. Index buffers allow us to get around this
problem. For simplicity though, we will not use an index buffer in this demo.
Rendering the scene
To draw our scene, we just need to add three lines of code to our RenderScene()
method so that it looks like the following:
public override void RenderScene()
{
if ((!this.IsInitialized) ||
this.IsDisposed)
{
return;
}
// Clear the screen before we draw the next
frame.
m_DeviceContext.ClearRenderTargetView(m_RenderTargetView,
ClearColor);
// Draw the triangle that we created in our
vertex buffer.
m_DeviceContext.Draw(3, 0);
// Present the frame we just rendered to
the user.
m_SwapChain.Present(0, PresentFlags.None);
}
Search WWH ::




Custom Search