I have a program capable of rendering 3D graphics using Direct3D11 and it is currently compatible with two different texture formats, TGA and DDS. The code to read and load a TGA texture in memory I'm using was from Rastertek tutorials here and it handle TGA textures which are upside down by reading their bytes backwards, but the code to read and load a DDS texture I'm using is just D3DX11CreateShaderResourcesViewFromFile
function from D3DX11tex.h
, and it was good enough for me until a while ago.
Now I'm facing a problem as some of DDS textures I want to use are upside down in a similar way to the TGA textures, so I need somehow a code where I can control how it reads the texture so I can modify it to read the DDS texture upside-down.
I've read this article from Microsoft, but even their simplest code is far more complex than the code from Rastertek to TGA file. It's not clear to me how I can implement a method to read a DDS upside-down.
What I 'think' I understand about TGA's data it that its first 18 bytes are their header and the rest is 4 bytes for each pixel(in a RGBA style), but I really don't understand how DDS works.