Loading DDS textures

Hi all, after months of reading, this is my first post here; I hope somebody can solve a weird problem I am suffering loading dds image files into my app. (My english is very bad but i’ll try my best)

I have followed all steps covered in the texture compression tutorial from the nVidia SDK and when I display the texture this is rendered vertically reversed; I noticed that, in the nVidia demo, the image files are previously reversed to achieve the desired results, but this disappointed me because I have seen a lot of demos and games that use compression and dds files that are “right” (i.e. Humus demos, but i can’t follow the code of his über framework (your work is awesome)).

So, it will be very nice if someone could spare some gl_lights on this… i’m very, very lost.

Thanks in advance. :slight_smile:

Usually you either flip the image in memory after you load it or you flip the texture coordinates when using the texture.

You could try using the nv_dds class that we use in NVIDIA developer demos, here are links to the necessary files:

http://cvs1.nvidia.com/DEMOS/OpenGL/inc/shared/nv_dds.h
http://cvs1.nvidia.com/DEMOS/OpenGL/src/shared/nv_dds.cpp

Its pretty simple to use, here’s an example:

CDDSImage image;
image.load(“myimage.dds”);
image.upload_texture2D();

It supports 1D, 2D, rectangle, 3D, and volume textures, supports mipmaps, compressed textures, etc… The class also works in Mac/Linux/Windows.

[This message has been edited by jra101 (edited 03-20-2003).]

In my oppinion the dds tools on NVidia site are wrong. There are other commersial tools that output “dds” images not flipped.

What is upside down is defined by what way you decide you want your texture coordinates to go. I prefer my upper-left corner of the texture to map to (0,0) and the lower-left be (0,1). Others prefer it the other way around. Depending on different definition different image file formats are stored with y going in different directions. For me .bmp and .tga are upside down while .dds are the right way. If you have loaded .bmp or .tga just the way they are in the file, .dds files will appear upside down. In my code, I flip the .tga and .bmp files to match what I consider be the right way.

Well, the TGA format has a byte in the header that tells you in what direction the image is stored. It’s the byte right after the byte that tells you the number of bits per pixel. If this byte has bit 6 set (0x20), then the image is stored bottom to top, and your image loader should handle this respectively. Some image editing programs do not give you this option (photoshop does not I believe) and some do (the GIMP for instance).

[This message has been edited by fenris (edited 03-20-2003).]

Thank you all,

I got little look at the nv_dds class and looks like what I want, I spoted some swapping functions that could match.

The Humus solution looks so nice too, I think it’s easier to swap uncompressed images that compressed ones.

Thanks again, I’ll notify my progress.

Ya, swapping the compressed textures is not fun, especially DXT5. The nv_dds class flips everything correctly though.