Now when I try to use the code, it complains:
ERROR: ID3D10Device::CreateTexture2D: A multisampled Texture2D cannot be bound to certain parts of the graphics pipeline, but must have at least one BindFlags bit set. The following BindFlags bits (0) cannot be set in this case: D3D10_BIND_VERTEX_BUFFER (0), D3D10_BIND_INDEX_BUFFER (0), D3D10_BIND_CONSTANT_BUFFER (0), D3D10_BIND_STREAM_OUTPUT (0)
Note- this happens when I call CreateTexture2D(). However, if I take the hint and try a BindFlag with my created texture (D3D10_BIND_RENDER_TARGET for example) I get the exact same error message when D3DX10SaveTextureToFile() is called.
Here is the code:
ID3D10Resource* pScreen; mpRenderTargetView->GetResource( &pScreen ); HRESULT hr; D3D10_TEXTURE2D_DESC texDesc; texDesc.ArraySize = 1; texDesc.BindFlags = D3D10_BIND_RENDER_TARGET; texDesc.CPUAccessFlags = 0; texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; texDesc.Width = (unsigned int)mWindowSize.x; texDesc.Height = (unsigned int)mWindowSize.y; texDesc.MipLevels = 1; texDesc.MiscFlags = 0; texDesc.SampleDesc.Count = 8; texDesc.SampleDesc.Quality = 0; texDesc.Usage = D3D10_USAGE_DEFAULT; ID3D10Texture2D *texture; hr = mpD3DDevice->CreateTexture2D( &texDesc, 0, &texture ); mpD3DDevice->CopyResource( texture, pScreen ); char* filename = "TestFile.dds" D3DX10SaveTextureToFile( texture, D3DX10_IFF_DDS, filename ); texture->Release(); pScreen->Release();
I should also mention that I've tried various file formats with no success yet. This function has been a real pain in the butt- if anyone can offer some help with this I'd really appreciate it!