I am really frustrated because my cbufer isn't updating. This is my VS:
cbuffer MatrixBuffer: register(b0)
{
float4x4 worldViewProj;
};
struct VertexIn
{
float4 Pos : POSITION;
float4 Color: COLOR;
};
struct PixelIn
{
float4 PosH : SV_POSITION;
float4 Color: COLOR;
};
PixelIn VS (VertexIn vin)
{
PixelIn vout;
vin.Pos.w = 1.0f;
vout.PosH = mul(vin.Pos, worldViewProj);
vout.Color = vin.Color;
return vout;
}
PixelIn VS1(VertexIn vin)
{
PixelIn vout;
vin.Pos.w = 1.0f;
vout.PosH = vin.Pos;
vout.Color = vin.Color;
return vout;
}
When using VS1 it draws correctly, but when using VS it doesn't draw anything?
Here is my CBUFFER update code
bool Game::UpdateShaders()
{
HRESULT result;
D3D11_MAPPED_SUBRESOURCE mappedResource;
MatrixBufferType* dataPtr;
worldViewProjM = worldM * viewM * projM;
worldViewProjM = XMMatrixTranspose(worldViewProjM);
result = md3dDeviceContext->Map(mMatrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
MessageBoxW(mMainWnd, L"FAOE:", 0, 0);
return false;
}
dataPtr = (MatrixBufferType*)mappedResource.pData;
dataPtr->worldViewProj = worldViewProjM;
md3dDeviceContext->Unmap(mMatrixBuffer, 0);
int NBuffers = 0;
md3dDeviceContext->VSSetConstantBuffers(0, 1, &mMatrixBuffer);
//md3dDeviceContext->PSSetConstantBuffers(0, 1, &mMatrixBuffer);
return true;
}
Here is my MATRIXBUFFERTYPE struct:
struct MatrixBufferType
{
XMMATRIX worldViewProj;
};
This is called after I clear my depth stencil view and render target view. Does somebody know why my CBUFFER isn't updating?
Thanks in advance.