I'm trying to change the data in a Texture2D with Map/Unmap and am running into an issue where the texture seems to only appear in the top 5th of the screen and the rest is just random pixels. (screenshot for clarification)
Here's some code:
uint32_t* m_colorBuffer; //buffer to fill the texture with random colors
D3D11_SUBRESOURCE_DATA m_textureData;
ID3D11Texture2D* m_texture;
D3D11_MAPPED_SUBRESOURCE mappedResource;
m_deviceContext->Map(m_texture, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
uint32_t rowSize = 256 * 4;
BYTE* mappedData = reinterpret_cast<BYTE*>(mappedResource.pData);
for (int i = 0; i < 256; i++) {
memcpy(mappedData, &(m_colorBuffer[i*rowSize]), rowSize);
mappedData += mappedResource.RowPitch;
}
m_deviceContext->Unmap(m_texture, 0);
Can Someone please tell me what I'm doing wrong here?
I'd be happy to supply more code if needed.