Game Development Reference
In-Depth Information
SAFE_RELEASE(m_pVertexShader);
SAFE_RELEASE(m_pcbVSMatrices);
SAFE_RELEASE(m_pcbVSMaterial);
SAFE_RELEASE(m_pcbVSLighting );
}
If you don ' t call SAFE_RELEASE for those Direct3D objects, you are sure to get one
of those dreaded warning messages at the exit of your game! The two meaty methods
of this class are OnRestore() , which initializes this class, and SetupRender() ,
which is called any time the shader is used to render graphics to the screen. Here is
OnRestore() :
HRESULT GameCode4_Hlsl_VertexShader::OnRestore()
{
HRESULT hr;
SAFE_RELEASE(m_pVertexLayout11);
SAFE_RELEASE(m_pVertexShader);
SAFE_RELEASE(m_pcbVSMatrices);
SAFE_RELEASE(m_pcbVSMaterial);
SAFE_RELEASE(m_pcbVSLighting );
//============================================================
// Load and compile the vertex shader. Using the lowest
// possible profile for broadest feature level support
ID3DBlob* pVertexShaderBuffer = NULL;
std::string hlslFileName =
Effects\\GameCode4_VS.hlsl
;
Resource resource(hlslFileName.c_str());
shared_ptr<ResHandle> pResourceHandle =
g_pApp->m_ResCache->GetHandle(&resource); if ( FAILED
(CompileShader(pResourceHandle->Buffer(), pResourceHandle->Size(),
hlslFileName.c_str(),
GameCode4_VSMain
,
vs_4_0_level_9_1
,
&pVertexShaderBuffer ) ) )
{
SAFE_RELEASE ( pVertexShaderBuffer );
return hr;
}
if ( FAILED ( DXUTGetD3D11Device()->CreateVertexShader(
pVertexShaderBuffer->GetBufferPointer(),
pVertexShaderBuffer->GetBufferSize(), NULL, &m_pVertexShader ) ) )
{
SAFE_RELEASE ( pVertexShaderBuffer );
return hr;
}
Search WWH ::




Custom Search