I'm using DX11. I'm not entirely sure how to put floats into the buffer, could you point me to a code sample? The only way I know how to do it is the following, and that's just with ints.
D3D11_MAPPED_SUBRESOURCE mappedResource;
result = deviceContext->Map(m_renderTargetTexture, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if(result != S_OK)
{
return false;
}
UCHAR* pTexels = (UCHAR*)mappedResource.pData;
//For 3D do the same but add "depthStart" as mappedResource.DepthPitch * depth
for( UINT row = 0; row < textureDesc.Height; row++ )
{
//Row number * height
UINT rowStart = row * mappedResource.RowPitch;
for( UINT col = 0; col < textureDesc.Width; col++ )
{
//width * number of channels (r,g,b,a)
UINT colStart = col * 4;
if( row > (textureWidth*0.4) && row < (textureWidth*0.6) )
{
pTexels[rowStart + colStart + 0] = 255; // Red
pTexels[rowStart + colStart + 1] = 0; // Green
pTexels[rowStart + colStart + 2] = 0; // Blue
pTexels[rowStart + colStart + 3] = 255; // Alpha
}
else
{
pTexels[rowStart + colStart + 0] = 0; // Red
pTexels[rowStart + colStart + 1] = 255; // Green
pTexels[rowStart + colStart + 2] = 0; // Blue
pTexels[rowStart + colStart + 3] = 255; // Alpha
}
}
}
deviceContext->Unmap(m_renderTargetTexture, 0);