Game Development Reference
In-Depth Information
//Render
D3D11_PRIMITIVE_TOPOLOGY PrimType;
for( UINT subset = 0; subset < extra->m_Mesh11.GetNumSubsets(0); ++subset )
{
// Get the subset
SDKMESH_SUBSET *pSubset = extra->m_Mesh11.GetSubset( 0, subset );
PrimType = CDXUTSDKMesh::GetPrimitiveType11(
( SDKMESH_PRIMITIVE_TYPE )pSubset->PrimitiveType );
DXUTGetD3D11DeviceContext()->IASetPrimitiveTopology( PrimType );
ID3D11ShaderResourceView* pDiffuseRV = extra->m_Mesh11.GetMaterial(
pSubset->MaterialID )->pDiffuseRV11;
DXUTGetD3D11DeviceContext()->PSSetShaderResources( 0, 1, &pDiffuseRV );
DXUTGetD3D11DeviceContext()->DrawIndexed( ( UINT )pSubset->IndexCount, 0,
( UINT )pSubset->VertexStart );
}
return S_OK;
}
Rendering geometry requires setting the vertex and index buffers, defining a primi-
tive topology, setting texture resources, and finishing with a draw call. In the case of a
mesh, you may have many different types of geometry using multiple textures. That
s
why there ' s a loop, similar to what you saw earlier with the skybox, except all the
skybox did was reset the texture. This shows that in the case of a mesh, you can
even reset the primitive topology. That implies something really important: A single
vertex buffer and a single index buffer can contain multiple primitive topologies! Tri-
angle lists, strips, line lists, strips, and others can all be represented in a single vertex
and index buffer pair.
'
Watch Those Long Load Times
Balancing load times and runtime frame rate is one of the trickiest problems
in game development. Load times tend to be slow because the files are
intentionally stripped down to the bare bones and compressed to pack as
many game assets on the digital media as possible. Frame rate suffers if the
game assets have to be tweaked every frame or
if
they simply aren
'
t
formatted for the fastest rendering on the player
'
s hardware. Here
'
s a good
rule of thumb: Don
t make the player wait more than 60 seconds for a load
for every 30 minutes of gameplay. And whatever you do, make sure you have
a nice screen animation during the load so players don
'
'
t confuse your long
load times with a game crash!
 
Search WWH ::




Custom Search