Game Development Reference
In-Depth Information
ShaderSignature m_VShaderSignature;
PixelShader m_PixelShader;
SlimDX.Direct3D11.Buffer m_VertexBuffer;
The m_Device variable will hold our Direct3D device object. The
m_DeviceContext variable is just a convenience variable that holds the device
context for us. This shortens some lines of code since we don't have to access it
through m_Device .
The m_RenderTargetView variable will hold our RenderTargetView object,
which is similar to the RenderTarget object we worked with in Chapter 3 , Render-
ing 2D Graphics . This is basically our Direct3D render target.
The m_SwapChain variable will hold our swap chain . The swap chain is just a chain
of buffers. Remember that a buffer is just an area in memory for storing data. The
simplest swap chain would have two buffers, which hold the graphics that our pro-
gram is drawing. Each time we draw a new frame, the buffers get swapped, so the
buffer containing our new frame becomes visible on the screen. The buffer we draw
into is called the back buffer because it is behind the scenes, so the player cannot
see it while we are drawing the next frame. The buffer that is currently displayed on
the screen is called the front buffer . When the buffers get swapped, the back buffer
becomes the new front buffer and vice versa.
At first, this may seem like a waste of memory. Why not just draw into the buffer
that is currently displayed onscreen so we can have one buffer rather than two? The
reason is that doing so can cause some flickering. This is because the player could
see things appear on the screen as they are being drawn. So instead, we draw into
an offscreen buffer until the frame is fully drawn. Then, we swap the buffers so that
the new frame appears on the screen all at once. This makes for smoother anima-
tion. This rendering technique is called double buffering . You can add more buf-
fers in between the back buffer and the front buffer as well. If you add one additional
buffer in between them, you will be doing triple buffering , which actually provides
speed improvement over double buffering.
Back to our member variables; the next one is m_Viewport . The view port simply
specifies the area of the render target that we want to draw on. It also specifies the
Search WWH ::




Custom Search