Search code examples
directx-11texture2d

How to set ID3D11Texture2D texels by hand?


Im going to make a raytracer, and I want to store my render data on a ID3D11Texture2D, so that I can display it or easily save to file using DX11, but I dont know how to initialize ID3D11Texture2D with the data I will have (probably an array of 32 bit RGB color)..


Solution

  • You can either specify pInitialData in CreateTexture2D if you know the contents already at creation time, or call UpdateSubresource (MSDN) or Map (MSDN)/Unmap (MSDN) on the texture to fill it with your raw values.