The code snippet don't want to work this time...
// Map the texture.
GetD3DContext()->Map(texture, 0, D3D11_MAP_WRITE_DISCARD, 0, &data);
// All pixels red just for testing.
for(int i = 0; i < mInfo.HeightmapWidth * mInfo.HeightmapHeight; i++)
redVector.push_back(XMFLOAT3(1, 0, 0));
const uint32_t pixelSize = sizeof(XMFLOAT3); // 12
const uint32_t srcPitch = pixelSize * mInfo.HeightmapWidth;
uint8_t* textureData = reinterpret_cast<uint8_t*>(data.pData);
const uint8_t* srcData = reinterpret_cast<uint8_t*>(redVector.data());
for(uint32_t i = 0; i < mInfo.HeightmapHeight; ++i)
memcpy(textureData, srcData, srcPitch);
textureData += data.RowPitch;
srcData += srcPitch;
This is what the texture looks like after mapping and updating it:
As you can see there is a stripe pattern and the color of the texture is not red as it is suppose to be. I don't know why this is the case but since I'm memcpy()ing in a row fassion then it maybe has something to do with that?