Question

How would I load a dds texture file into an OpenGL 2dtexture or cube map texture?

Was it helpful?

Solution

I believe you use the glCompressedTexImage2DARB method and its friends.

This PDF seems to contain some promising info that may be helpful to you.

OTHER TIPS

Depending on your needs, the DevIL library can take care of feeding OpenGL with a DDS file content.

If the DDS contains a compressed texture then use glCompressedTexImage2DARB(), if it contains uncompressed data the usual glTexImage2D procedure applies. Once for each mipmap level if the DDS file contains mipmaps, and once for each cubemap face if its a cubemap.

For how to go about reading the header and data in a DDS file look up the documentation for it on MSDN or in the DirectX SDK. It's a fairly standard container format, there aren't too many surprises.

Be aware that DDS uses a top-left image origin whereas OpenGL assumes a bottom-left origin for image data. This means you will probably want to vertically flip a DDS image after loading it in. You can do this without decompressing them if they are in DXT1/3/5, but it's a slightly fiddly process that involves bit manipulation on the contents of each 4x4 compression block.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top