Each valid filter must contain exactly one of the following flags: D3DX_FILTER_NONE, D3DX_FILTER_POINT, D3DX_FILTER_LINEAR, D3DX_FILTER_TRIANGLE, or D3DX_FILTER_BOX. In addition, you can use the OR operator to specify zero or more of the following optional flags with a valid filter: D3DX_FILTER_MIRROR_U, D3DX_FILTER_MIRROR_V, D3DX_FILTER_MIRROR_W, D3DX_FILTER_MIRROR, D3DX_FILTER_DITHER, D3DX_FILTER_SRGB_IN, D3DX_FILTER_SRGB_OUT or D3DX_FILTER_SRGB. Specifying D3DX_DEFAULT for this parameter is usually the equivalent of specifying D3DX_FILTER_TRIANGLE | D3DX_FILTER_DITHER. However, D3DX_DEFAULT can have different meanings, depending on which method uses the filter. For example: - When using D3DXCreateTextureFromFileEx, D3DX_DEFAULT maps to D3DX_FILTER_TRIANGLE | D3DX_FILTER_DITHER.
- When using D3DXFilterTexture, D3DX_DEFAULT maps to D3DX_FILTER_BOX if the texture size is a power of two, and D3DX_FILTER_BOX | D3DX_FILTER_DITHER otherwise.
Reference each method to check for information about how D3DX_DEFAULT filter is mapped. 参数pSrcInfo的类型D3DXIMAGE_INFO详细说明: Returns a description of the original contents of an image file. typedef struct D3DXIMAGE_INFO { UINT Width; UINT Height; UINT Depth; UINT MipLevels; D3DFORMAT Format; D3DRESOURCETYPE ResourceType; D3DXIMAGE_FILEFORMAT ImageFileFormat; } D3DXIMAGE_INFO, *LPD3DXIMAGE_INFO; Members- Width
- Width of original image in pixels.
- Height
- Height of original image in pixels.
- Depth
- Depth of original image in pixels.
- MipLevels
- Number of mip levels in original image.
- Format
- A value from the D3DFORMAT enumerated type that most closely describes the data in the original image.
- ResourceType
- Represents the type of the texture stored in the file. It is either D3DRTYPE_TEXTURE, D3DRTYPE_VOLUMETEXTURE, or D3DRTYPE_CubeTexture.
- ImageFileFormat
- Represents the format of the image file.
参数pPalette的类型PALETTEENTRY的详细说明: Specifies the color and usage of an entry in a logical palette. typedef struct PALETTEENTRY { BYTE peRed; BYTE peGreen; BYTE peBlue; BYTE peFlags; } PALETTEENTRY, *LPPALETTEENTRY; Members- peRed
- The red intensity value for the palette entry.
- peGreen
- The green intensity value for the palette entry.
- peBlue
- The blue intensity value for the palette entry.
- peFlags
- The alpha intensity value for the palette entry. Note that as of DirectX 8, this member is treated differently than documented in the Platform SDK.
当背景色为透明黑色的纹理创建以后,就可以将该纹理对象所表示的图象透明地显示在其他图象的上面。
此时,需要设置渲染管道流水线的D3DRS_ALPHATESTENABLE状态值为TRUE,以开启Alpha测试。
D3DRS_ALPHATESTENABLE
TRUE to enable per pixel alpha testing. If the test passes, the pixel is processed by the frame buffer. Otherwise, all frame-buffer processing is skipped for the pixel. The test is done by comparing the incoming alpha value with the reference alpha value, using the comparison function provided by the D3DRS_ALPHAFUNC render state. The reference alpha value is determined by the value set for D3DRS_ALPHAREF. For more information, see Alpha Testing State (Direct3D 9).
The default value of this parameter is FALSE.
// enable per pixel alpha testing _d3d_device->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE); 接着设置D3DRS_ALPHAREF的状态为一个0~255范围内的整数值。
// specifies a reference alpha value against which pixels are tested _d3d_device->SetRenderState(D3DRS_ALPHAREF, 0x01); 再接着设置3DRS_ALPHAFUNC状态为D3DCMPFUNC的枚举值,决定测试将使用比较方式。 Defines the supported compare functions. typedef enum D3DCMPFUNC { D3DCMP_NEVER = 1, D3DCMP_LESS = 2, D3DCMP_EQUAL = 3, D3DCMP_LESSEQUAL = 4, D3DCMP_GREATER = 5, D3DCMP_NOTEQUAL = 6, D3DCMP_GREATEREQUAL = 7, D3DCMP_ALWAYS = 8, D3DCMP_FORCE_DWORD = 0x7fffffff, } D3DCMPFUNC, *LPD3DCMPFUNC; |