readback texture created with D3DX10CreateTextureFromFileA

Started by
0 comments, last by Assassin 15 years, 5 months ago
Is there a simple way of reading back the contents of a texture created with D3DX10CreateTextureFromFile ? I have attempted to get data from mipmap level zero but the first call to map () below fails:

D3D10_MAPPED_TEXTURE2D mappedTexture;
hr = md_pTexture->Map (D3D10CalcSubresource (0, 0, 0), 
  D3D10_MAP_READ, 0, &mappedTexture);

md_pTexture->Unmap (D3D10CalcSubresource (0, 0, 0));

Is there any official way of reading back texture data?
Advertisement
You can override the usage in the D3DX call with the D3DX10_IMAGE_LOAD_INFO parameter to load the texture as a staging resource with cpu read capability and no bind flags. Don't expect it to work as a shader resource after that, but you can read it with Map.
Assassin, aka RedBeard. andyc.org

This topic is closed to new replies.

Advertisement