bool TextureShader::SetShaderParameters(ID3D11DeviceContext *pContext, const XMMATRIX &worldMatrix, const XMMATRIX &viewMatrix, const XMMATRIX &projectionMatrix, ID3D11ShaderResourceView *pSrv, float width, float height, float xRes, float yRes, Vec2f poi, Vec2f poi2) { HRESULT result; D3D11_MAPPED_SUBRESOURCE mappedResource; MatrixBufferType *transformDataBuffer; unsigned int bufferNumber; // Lock the constant buffer so it can be written to. result = pContext->Map(m_pMatrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource); if (FAILED(result)) { return false; } transformDataBuffer = (MatrixBufferType *)mappedResource.pData; // Transpose the matrices for shader and copy them into the constant buffer. transformDataBuffer->world = XMMatrixTranspose(worldMatrix); transformDataBuffer->view = XMMatrixTranspose(viewMatrix); transformDataBuffer->projection = XMMatrixTranspose(projectionMatrix); // Unlock the constant buffer. pContext->Unmap(m_pMatrixBuffer, 0); bufferNumber = 0; pContext->VSSetConstantBuffers(bufferNumber, 1, &m_pMatrixBuffer); // Pixel shader constant buffer result = pContext->Map(m_perFameBufferPS, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource); if (FAILED(result)) { return false; } PerFrameBufferTypePS *pPerFrameDataBufferPS = (PerFrameBufferTypePS *)mappedResource.pData; pPerFrameDataBufferPS->width = width; pPerFrameDataBufferPS->height = height; pPerFrameDataBufferPS->xRes = xRes; pPerFrameDataBufferPS->yRes = yRes; pPerFrameDataBufferPS->poi = poi.GetAsXMFloat2(); pPerFrameDataBufferPS->poi2 = poi2.GetAsXMFloat2(); pContext->Unmap(m_perFameBufferPS, 0); pContext->PSSetConstantBuffers(1, 1, &m_perFameBufferPS); pContext->PSSetShaderResources(0, 1, &pSrv); return true; }