Platform SDK: DirectX

Texture Compression

DirectDraw provides services to compress surfaces that will be used for texturing 3-D models. For information on creating and manipulating the data in a compressed texture surface, see Compressed Texture Surfaces in the DirectDraw documentation.

[C++]

Once your application creates a rendering device, it can determine if the device supports texturing from compressed texture surfaces by calling the IDirect3DDevice7::EnumTextureFormats method. The method calls the D3DEnumPixelFormatsCallback callback function that you provide for each pixel format that the device supports for texture maps. If any of the enumerated pixel formats use the DXT1, DXT2, DXT3, DXT4, or DXT5 four character codes (FOURCCs), the device can texture directly from a compressed texture surface that uses that format. If so, you can use compressed texture surfaces directly with Direct3D by calling the IDirect3DDevice7::SetTexture method. If the device doesn't support texturing from compressed texture surfaces, you can still store texture data in a compressed format surface, but you must convert any compressed textures to a supported format before they can be used for texturing. The DirectDraw blit methods, IDirectDrawSurface7::Blt and IDirectDrawSurface7::BltFast, automatically perform conversion of compressed formats to standard RGBA formats. To minimize loss of information, try to pick a destination pixel format that closely matches the compressed format. For instance, ARGB:1555 would be a good destination format for DXT1, but ARGB:4444 would be a better choice for DXT3 since DXT3 contains four bits of alpha information.

[Visual Basic]

Once your application creates a rendering device, it can determine if the device supports texturing from compressed texture surfaces by calling the Direct3DDevice7.GetTextureFormatsEnum method. The method returns a reference to a Direct3DEnumPixelFormats class object, which exposes methods to retrieve information about the supported texture surface pixel formats. The Direct3DEnumPixelFormats.GetItem method fills a DDPIXELFORMAT type to describe a supported texture format. If any of the enumerated pixel formats use the DXT1, DXT2, DXT3, DXT4, or DXT5 four character codes (FOURCCs), the device can texture directly from a compressed texture surface that uses that format. If so, you can use compressed texture surfaces directly with Direct3D by calling the Direct3DDevice7.SetTexture method. If the device doesn't support texturing from compressed texture surfaces, you can still store texture data in a compressed format surface, but you must convert any compressed textures to a supported format before they can be used for texturing. The DirectDraw blit methods, DirectDrawSurface7.Blt and DirectDrawSurface7.BltFast, automatically perform conversion of compressed formats to standard RGBA formats. To minimize loss of information, try to pick a destination pixel format that closely matches the compressed format. For instance, ARGB:1555 would be a good destination format for DXT1, but ARGB:4444 would be a better choice for DXT3 since DXT3 contains four bits of alpha information.