4

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

3 Answers 3

4

I believe you use the glCompressedTexImage2DARB method and its friends.

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

Sign up to request clarification or add additional context in comments.

Comments

3

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

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.