Game Development Reference
In-Depth Information
The first variable holds the position of the vertex in 3D space. The second one stores
a color for this vertex, and the third variable stores the texture coordinates for this
vertex. The texture coordinates simply define how the texture is applied to the poly-
gon. For example, to texture a square, you'd give the upper-left vertex (0,0) for
its texture coordinates. The upper-right vertex would be (1,0) , the lower-left vertex
wouldbe (0,1) ,andthelower-rightvertexwouldhave (1,1) foritstexturecoordin-
ates. In the texture coordinates, (0,0) is the upper-left corner of the texture image,
and (1,1) represents the bottom-right corner of the texture image. So, the texture
coordinates we just saw would make the texture fill the entire face of the square.
They are basically attaching the top-left corner of the texture to the top-left corner
of the square, the bottom-right corner of the texture to the bottom-right corner of the
square, and so on.
Now, we will need to add a few sets of new member variables. The first one is for
our constant buffers . A constant buffer is just a buffer that we use to communicate
certain information to the video card, such as the projection and view matrices. We
have four variables for our constant buffers:
SlimDX.Direct3D11.Buffer m_CbChangesOnResize;
SlimDX.Direct3D11.Buffer m_CbChangesPerFrame;
SlimDX.Direct3D11.Buffer m_CbChangesPerObject;
// We use this to send data into the constant
buffers.
DataStream m_DataStream;
The first three variables will hold our three constant buffers. But why do we have
three? The reason is that it's more efficient this way compared to using only one.
The m_CbChangesOnResize buffer will hold the projection matrix that only needs
to change when the window is resized. In this demo, this never changes since we
just let it keep rendering at the same resolution and stretch it to fit the window. By
having it in a separate buffer, we never have to change it unless the window changes
size, which saves time. The m_CbChangesPerFrame buffer will hold our view mat-
rix, which can change per frame any time that you press one of the movement keys.
And lastly, the m_CbChangesPerObject buffer will hold information that is object-
specific. This buffer would be updated each time before you draw the next object in
your scene by filling it with the information for that object.
Search WWH ::




Custom Search