DDS texture loading

瘦欲@ 提交于 2019-12-10 10:20:00

问题


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


回答1:


I believe you use the glCompressedTexImage2DARB method and its friends.

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




回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/577125/dds-texture-loading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!