Microsoft DirectX 8.0 (Visual Basic) |
After creating a device that supports a compressed texture format on the adapter, you can create a compressed texture resource. Call Direct3DDevice8.CreateTexture and specify a compressed texture format for the Format parameter.
Before loading an image into a texture object, retrieve a pointer to the texture surface by calling the Direct3DTexture8.GetSurfaceLevel method.
Now you can use any D3DX function that begins with D3DXLoadSurface to load an image into the surface that was retrieved by using GetSurfaceLevel. These functions handle conversion to and from compressed texture formats.
You can create and convert compressed texture (DDS) files using the DXTex Tool supplied with the SDK. You can also create your own DDS files.
The advantage of this behavior is that an application can copy the contents of a compressed surface to a file without calculating how much storage is required for a surface of a particular width and height in the specific format.
The following table shows the five types of compressed textures. For more information on how the data is stored, see Compressed Texture Formats. You only need this information if you are writing your own compression routines.
FOURCC | Description | Alpha-premultiplied? |
---|---|---|
DXT1 | Opaque / one-bit alpha | N/A |
DXT2 | Explicit alpha | Yes |
DXT3 | Explicit alpha | No |
DXT4 | Interpolated alpha | Yes |
DXT5 | Interpolated alpha | No |
Note When you transfer data from a non-premultiplied format to a premultiplied format, Direct3D scales the colors based on the alpha values. Transferring data from a premultiplied format to a non-premultiplied format is not supported. If you try to transfer data from a premultiplied-alpha source to a non-premultiplied-alpha destination, the method returns D3DERR_INVALIDCALL. If you transfer data from a premultiplied-alpha source to a destination that has no alpha, the source color components, which have been scaled by alpha, are copied as is.