Original Post
Hello, I am studying the CComPtr class but when I try to use it in the D3D10Effect class of my engine it doesn't draw anything on the screen. Here's my code:
header file:
source file:
The problem is caused by the "CComPtr inputlayout" parameter: if I change it to "ID3D10InputLayout *inputlayout" the engine draws the meshes even if I use CComPtr for the other DirectX objects.
Could you tell I am wrong?
PS: Other comments regarding the code style are welcome.
Thank you!
header file:
class D3DEffect : public Effect{ public: // Constructor D3DEffect( const std::string &filename, CComPtr <ID3D10Device> device, CComPtr <ID3D10InputLayout> inputlayout ); // Destructor ~D3DEffect(); // Selects the effect void Use(); // Gets the effect void* GetEffect(); // Sets the matrix void SetMatrix( const std::string &name, Matrix4D &matrix ); private: // Declares a DX10 Effect CComPtr <ID3D10Effect> effect;};source file:
D3DEffect::D3DEffect( const std::string& filename, CComPtr <ID3D10Device> device, CComPtr<ID3D10InputLayout> inputlayout ){ HRESULT hr; // Clears the memory ZeroMemory( &effect, sizeof( ID3D10Effect ) ); // Creates the effect hr = D3DX10CreateEffectFromFile( filename.c_str(), NULL, NULL, "fx_4_0", D3D10_SHADER_ENABLE_STRICTNESS, NULL, device, NULL, NULL, &effect, NULL, NULL ); // Checks if the effect has been created if( FAILED( hr ) ) MessageBox( NULL, _T( "Cannot create the effect!" ), _T( "Essence" ), NULL ); D3D10_PASS_DESC passDesc; // Gets the correct pass descriptor effect->GetTechniqueByIndex( 0 )->GetPassByIndex( 0 )->GetDesc( &passDesc ); D3D10_INPUT_ELEMENT_DESC layout[] = { { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 }, { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, sizeof(float) * 12, D3D10_INPUT_PER_VERTEX_DATA, 0 } }; UINT elements = sizeof( layout ) / sizeof( layout[0] ); // Crea il layout per la definizione del vertice hr = device->CreateInputLayout( layout, elements, passDesc.pIAInputSignature, passDesc.IAInputSignatureSize, &inputlayout ); if( FAILED( hr ) ) MessageBox( NULL, _T( "Cannot create the effect!" ), _T( "Essence" ), NULL ); device->IASetInputLayout( inputlayout );}D3DEffect::~D3DEffect(){}and so on...The problem is caused by the "CComPtr
Could you tell I am wrong?
PS: Other comments regarding the code style are welcome.
Thank you!