Microsoft DirectX 8.1 (C++)

D3DFORMAT

Defines the various types of surface formats. The format determines the type of surface data and the number of bits reserved for each type of data. Several types of formats exist because there are several types of surfaces.

Unsigned Formats

Data in an unsigned format must be positive. Unsigned formats use combinations of (R)ed, (G)reen, (B)lue, (A)lpha, (L)uminance, and (P)alette data. Palette data is also referred to as color indexed data because the data is used to index a color palette.

Unsigned format flags Format
D3DFMT_R8G8B8 24-bit RGB pixel format with 8 bits per channel.
D3DFMT_A8R8G8B8 32-bit ARGB pixel format with alpha, using 8 bits per channel.
D3DFMT_X8R8G8B8 32-bit RGB pixel format, where 8 bits are reserved for each color.
D3DFMT_R5G6B5 16-bit RGB pixel format with 5 bits for red, 6 bits for green, and 5 bits for blue.
D3DFMT_X1R5G5B5 16-bit pixel format where 5 bits are reserved for each color.
D3DFMT_A1R5G5B5 16-bit pixel format where 5 bits are reserved for each color and 1 bit is reserved for alpha.
D3DFMT_A4R4G4B4 16-bit ARGB pixel format with 4 bits for each channel.
D3DFMT_A8 8-bit alpha only.
D3DFMT_R3G3B2 8-bit RGB texture format using 3 bits for red, 3 bits for green, and 2 bits for blue.
D3DFMT_A8R3G3B2 16-bit ARGB texture format using 8 bits for alpha, 3 bits each for red and green, and 2 bits for blue.
D3DFMT_X4R4G4B4 16-bit RGB pixel format using 4 bits for each color.
D3DFMT_A2B10G10R10 32-bit pixel format using 10 bits for each color and 2 bits for alpha.
D3DFMT_G16R16 32-bit pixel format using 16 bits each for green and red.
D3DFMT_A8P8 8-bit color indexed with 8 bits of alpha.
D3DFMT_P8 8-bit color indexed.
D3DFMT_L8 8-bit luminance only.
D3DFMT_A8L8 16-bit using 8 bits each for alpha and luminance.
D3DFMT_A4L4 8-bit using 4 bits each for alpha and luminance.

Signed Formats

Data in a signed format can be both positive and negative. Signed formats use combinations of (U), (V), (W), and (Q) data.

Signed format flags Format
D3DFMT_V8U8 16-bit bump-map format using 8 bits each for u and v data.
D3DFMT_Q8W8V8U8 32-bit bump-map format using 8 bits for each channel.
D3DFMT_V16U16 32-bit bump-map format using 16 bits for each channel.
D3DFMT_W11V11U10 32-bit bump-map format using 11 bits each for w and v, and 10 bits for u.

Mixed Formats

Data in mixed formats can contain a combination of unsigned data and signed data.

Mixed format flags Format
D3DFMT_L6V5U5 16-bit bump-map format with luminance using 6 bits for luminance, and 5 bits each for u and v.
D3DFMT_X8L8V8U8 32-bit bump-map format with luminance using 8 bits for each channel.
D3DFMT_A2W10V10U10 32-bit bump-map format using 2 bits for alpha and 10 bits each for w, v, and u.

FourCC Formats

Data in a FourCC format is compressed data.

FourCC flags Format
D3DFMT_UYVY UYVY format (PC98 compliance)
D3DFMT_YUY2 YUY2 format (PC98 compliance)
D3DFMT_DXT1 DXT1 compression texture format
D3DFMT_DXT2 DXT2 compression texture format
D3DFMT_DXT3 DXT3 compression texture format
D3DFMT_DXT4 DXT4 compression texture format
D3DFMT_DXT5 DXT5 compression texture format

Buffer Formats

Depth, stencil, vertex, and index buffers each have unique formats.

Buffer flags Format
D3DFMT_VERTEXDATA Describes a vertex buffer surface.
D3DFMT_INDEX16 16-bit index buffer bit depth.
D3DFMT_INDEX32 32-bit index buffer bit depth.
D3DFMT_D16_LOCKABLE 16-bit z-buffer bit depth. This is an application-lockable surface format.
D3DFMT_D32 32-bit z-buffer bit depth.
D3DFMT_D15S1 16-bit z-buffer bit depth where 15 bits are reserved for the depth channel and 1 bit is reserved for the stencil channel.
D3DFMT_D24S8 32-bit z-buffer bit depth using 24 bits for the depth channel and 8 bits for the stencil channel.
D3DFMT_D16 16-bit z-buffer bit depth.
D3DFMT_D24X8 32-bit z-buffer bit depth using 24 bits for the depth channel.
D3DFMT_D24X4S4 32-bit z-buffer bit depth using 24 bits for the depth channel and 4 bits for the stencil channel.

All depth-stencil formats except D3DFMT_D16_LOCKABLE indicate no particular bit ordering per pixel, are not application-lockable, and the driver is allowed to consume more than the indicated number of bits per depth channel (but not stencil channel).

Other

This only other flag used is for undefined formats.

Other flags Format
D3DFMT_UNKNOWN Surface format is unknown.

Remarks

Render target formats are restricted to D3DFMT_X1R5G5B5, D3DFMT_R5G6B5, D3DFMT_X8R8G8B8, and D3DFMT_A8R8G8B8.

The order of the bits are from the most significant bit (MSB) first, so D3DFMT_A8L8 indicates that the high byte of this 2-byte format is alpha. D3DFMT_D16 indicates a 16-bit integer value and an application-lockable surface.

Pixel formats are denoted by opaque DWORD identifiers. The format of these DWORDs has been chosen to enable the expression of IHV-defined extension formats, and also to include the well-established FOURCC method. The set of formats understood by the Microsoft® Direct3D® runtime is defined by D3DFORMAT.

Note that IHV-supplied formats and many FOURCC codes are not listed in the D3DFORMAT enumeration. The formats in this enumeration are unique in that they are sanctioned by the runtime, meaning that the reference rasterizer will operate on all these types. The IHV-supplied formats will be supported by the individual IHVs on a card-by-card basis.

Requirements

  Header: Declared in D3d8types.h.

See Also

IDirect3D8::CheckDeviceFormat