Game Development Reference
In-Depth Information
//============================================================
// Create the vertex input layout and release the pVertexShaderBuffer object
if ( SUCCEEDED ( DXUTGetD3D11Device()->CreateInputLayout(
D3D11VertexLayout_UnlitTextured,
ARRAYSIZE( D3D11VertexLayout_UnlitTextured ),
pVertexShaderBuffer->GetBufferPointer(),
pVertexShaderBuffer->GetBufferSize(), &m_pVertexLayout11 ) );
{
//==========================================================
// Setup the constant buffer for the two transformation matrices
D3D11_BUFFER_DESC Desc;
Desc.Usage = D3D11_USAGE_DYNAMIC;
Desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
Desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
Desc.MiscFlags = 0;
Desc.ByteWidth = sizeof( ConstantBuffer_Matrices );
V_RETURN( DXUTGetD3D11Device()->CreateBuffer( &Desc, NULL,
&m_pcbVSMatrices ) );
Desc.ByteWidth = sizeof( ConstantBuffer_Material );
V_RETURN( DXUTGetD3D11Device()->CreateBuffer( &Desc, NULL,
&m_pcbVSMaterial ) );
Desc.ByteWidth = sizeof( ConstantBuffer_Lighting );
V_RETURN( DXUTGetD3D11Device()->CreateBuffer( &Desc, NULL,
&m_pcbVSLighting ) );
}
SAFE_RELEASE ( pVertexShaderBuffer );
return S_OK;
}
The first few lines simply release the D3D11 objects, if they happen to contain any-
thing. This might happen if the D3D11 device were lost, which could happen if the
player switched to another application or dragged the game from one monitor to
another.
The next section of code, defined by the comment headers, loads the shader from the
resource cache. The free function, CompileShader() , you
ve seen in the previous
section. The entry point of our shader is set to GameCode4_VSMain . The string
parameter for the shader model is set to vs_4_0_level_9_1 , which tells the shader
compiler to support vertex shaders model 4.0, compatible with Direct3D 9.1. The
compiled shader is stored in pVertexShaderBuffer . If the compile fails for any
'
Search WWH ::




Custom Search