View Full Version : Loading DDS textures
03-20-2003, 01:26 PM
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. :)
03-20-2003, 01:37 PM
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:
Its pretty simple to use, here's an example:
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).]
03-20-2003, 01:39 PM
In my oppinion the dds tools on NVidia site are wrong. There are other commersial tools that output "dds" images not flipped.
03-20-2003, 01:42 PM
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.
03-20-2003, 02:25 PM
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).]
03-20-2003, 02:32 PM
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.
03-20-2003, 02:41 PM
Ya, swapping the compressed textures is not fun, especially DXT5. The nv_dds class flips everything correctly though.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.