microsoft / DirectXTK

The DirectX Tool Kit (aka DirectXTK) is a collection of helper classes for writing DirectX 11.x code in C++
https://walbourn.github.io/directxtk/
MIT License
2.55k stars 506 forks source link

SaveDDSTextureToFile doesn't save cubemaps. #141

Closed comeradealexi closed 6 years ago

comeradealexi commented 6 years ago

Hi!

We're converting some legacy D3D9 code which used D3DXCreateCubeTextureFromFileEx and D3DXSaveTextureToFile to resize certain textures and we're now using DirectXTK and using CreateDDSTextureFromFile with SaveDDSTextureToFile.

However it appears SaveDDSTextureToFile doesn't work with cube maps. Our texture is a Texture2D with an array size of 6 but after calling SaveDDSTextureToFile, this information appears to be lost.

Is this a bug or is support for this simply not there? I can't see anywhere where it writes out to the DirectX header the information it needs to detect it as a cube map.

Thanks!

walbourn commented 6 years ago

This is covered in the wiki

These writers do not support array textures, 1D textures, 3D volume textures, or cubemaps. Mipmaps are also ignored. For those scenarios, use the DirectXTex library functionality. The ScreenGrab module is really designed to make a quick and light-weight solution for capturing screenshots at runtime.

See DirectXTex.

comeradealexi commented 6 years ago

Thanks Walbourn! I'll use DirectXTex instead :)

It would be good if it made this more aware to the end user with a log message or something similar. I only used the function as it was recommend from this article here as the conversion: https://blogs.msdn.microsoft.com/chuckw/2013/08/20/living-without-d3dx/

Anyway, thanks for the quick reply!

Alex

walbourn commented 6 years ago

I mentioned both in that article as well, but it really depends on what you were doing with it. D3DX suffered from having too many usage scenarios. DirectX Tool Kit is mostly focused on 'runtime' usage in games and apps, while DirectXTex is for content processing & tools. Most games only write textures for screenshots.

I do mention this in the comment block at the top of ScreenGrab.cpp:

Note these functions are useful as a light-weight runtime screen grabber. For
full-featured texture capture, DDS writer, and texture processing pipeline,
see the 'Texconv' sample and the 'DirectXTex' library.

Still, I'll add a DebugTrace message to help in future.