Not sure what to think on this, really confused.
I'll try to explain what I need to do best I can, its quite alot..
Firstly I have this method:
void MD5::RenderBuffers(ID3D11DeviceContext* deviceContext)
{
unsigned int stride;
unsigned int offset;
//Set the vertex and pixel shaders that will be used to render this model
deviceContext->VSSetShader(m_vertexShader, NULL, 0);
deviceContext->PSSetShader(m_pixelShader, NULL, 0);
//Set vertex buffer stride and offset
stride = sizeof(VertexType);
offset = 0;
for(int i = 0; i < m_NewMD5Model.numSubsets; i ++)
{
//Set the grounds index buffer
deviceContext->IASetIndexBuffer(m_NewMD5Model.subsets.indexBuff, DXGI_FORMAT_R32_UINT, 0);
//Set the grounds vertex buffer
deviceContext->IASetVertexBuffers(0, 1, &m_NewMD5Model.subsets.vertBuff, &stride, &offset);
WVP = world * view * projection;
m_cbPerObj.WVP = XMMatrixTranspose(WVP);
m_cbPerObj.World = XMMatrixTranspose(m_smilesWorld);
m_cbPerObj.hasTexture = true;
m_cbPerObj.hasNormMap = false;
deviceContext->UpdateSubresource(cbPerObjectBuffer, 0, NULL, &m_cbPerObj, 0, 0);
deviceContext->VSSetConstantBuffers(0, 1, &cbPerObjectBuffer);
deviceContext->PSSetConstantBuffers(1, 1, &cbPerObjectBuffer);
deviceContext->PSSetShaderResources(0, 1, &m_meshSRV[m_NewMD5Model.subsets.texArrayIndex]);
deviceContext->PSSetSamplers(0, 1, &m_CubesTexSamplerState);
deviceContext->RSSetState(m_RSCullNone);
//Draw
deviceContext->DrawIndexed(m_NewMD5Model.subsets.indices.size(), 0, 0 );
}
}
This method is used to render an MD5 model, by applying World Matrix properties and other values such as that from the shader.
This line here:
D3DXMATRIX WVP;
WVP = world * view * projection;
World, View and Projection need to know about this struct in the header file
struct MatrixBufferType
{
D3DXMATRIX world;
D3DXMATRIX view;
D3DXMATRIX projection;
};
but instead return errors like this:
Once these have correct values, I will be able to apply values to the WVP and World variables which reside inside the cbPerObj struct:
struct cbPerObject
{
XMMATRIX WVP;
XMMATRIX World;
BOOL hasTexture;
BOOL hasNormMap;
};
Which will finally give the correctly values for the variables within the UpdateSubresource parameters...
m_cbPerObj.WVP = XMMatrixTranspose(WVP);
m_cbPerObj.World = XMMatrixTranspose(m_smilesWorld);
m_cbPerObj.hasTexture = true;
m_cbPerObj.hasNormMap = false;
deviceContext->UpdateSubresource(cbPerObjectBuffer, 0, NULL, &m_cbPerObj, 0, 0);
But I'm not sure where I am going wrong, I'm aware theres a few crosses between XMMATRIX and D3DXMATRIX, these can be shortly after my first problem. Can anyone help?
EDIT:
I put the world, view, and projection matrix into the parameter of the method like so
void MD5::RenderBuffers(ID3D11DeviceContext* deviceContext, D3DXMATRIX worldMatrix, D3DXMATRIX viewMatrix, D3DXMATRIX projectionMatrix)
It has fixed the problem, I also changed a few XMMatrix and XMMatrixTranspose to it's D3DX Counter Part, which should makes things a bit smoother. Next problem I'm having this error I'm not sure what to make of it, it's asking for a pointer, any ideas?
WVP = worldMatrix * viewMatrix * projectionMatrix;
m_cbPerObj.WVP = D3DXMatrixTranspose(WVP);
m_cbPerObj.World = D3DXMatrixTranspose(m_smilesWorld);