1
\$\begingroup\$

I am learning DirectX with the DirectX Tool Kit library and everything seems to be going smoothly but I have run in to a tiny little hiccup.

I am currently trying to load DDS textures from file because this method is easier than loading common JPG or PNG files. The problem is that DDS images I create from Paint.NET work fine. Images in PNG or JPG file formats converted to DDS do not work and my program throws an exception.

  1. So does anyone have experience with this type of problem and if so, how did you solve the problem?
  2. Also is there any workflow oriented software I can use for creating DDS files?

I plan to make my application with DirectX and DirectXTK. (It is too late to turn back now...)

\$\endgroup\$
1
\$\begingroup\$

The question is what pixel format are you converting your JPG and PNG images to for the DDS, and with what tool?

Many of the older tools, including the legacy DirectX SDK texture tool, will default to using a 24bpp format D3DFMT_R8G8B8. The problem with this format is that there is no DXGI format that is 24bpp. The DDSTextureLoader in DirectX Tool Kit is designed for efficient runtime use, and therefore performs no conversions. Either the DDS file in question directly maps to a DXGI format, or it fails to load.

The texconv command-line tool in DirectXTex is a modern converter. It can load and convert older legacy DDS file formats that don't have DXGI equivalents as well. See Direct3D 11 Textures and Block Compression.

Depending on what format you are choosing to convert your DDS files into, there are potentially other points of failure based on your video card's Direct3D Feature Level. For example, you can't use a BC4 or BC5 texture on a Feature Level 9.x device.

The DDSTextureLoader functions don't throw C++ exceptions. They return HRESULT values. While a common pattern is to use DX::ThrowIfFailed to handle the return value, you can also inspect the HRESULT in the debugger which could well provide a clue as to why it failed.

See the DDSTextureLoader documentation for more for details.

PS: If you are new to DirectX, consider taking a look at the DirectX Tool Kit tutorials.

\$\endgroup\$
0
0
\$\begingroup\$

If Paint.net created dds files work for you and converted jpgs do not and you converted in a different software, convert jpgs to dds in Paint.net. You can also use DirectX texture tool provided with the DirectX SDK which I can say for sure works.

Also keep in mind if you use DXT compression, your textures must be power of two size.

Also try out different DDS texture formats and try switching mipmaps to on/off if you can still not load them.

\$\endgroup\$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.