Platform SDK: DirectX |
Direct3D devices can support texturing from texture surfaces that use attached palettes. These types of textures are sometimes called "palettized textures." A palettized texture is a DirectDrawSurface object, created with the DDSCAPS_TEXTURE capability, that uses one of the DDPF_PALETTEINDEXEDn pixel formats (where n is 1, 2, 4, or 8). These capabilities are included in the DDSURFACEDESC2 structure that you use to create a texture (and the DDPIXELFORMAT structure that the description contains). Like all palettized surfaces, instead of a color, each pixel is an index into a table of values held within an attached DirectDrawPalette object. For more information about creating and using palettized surfaces, see Surfaces and Palettes in the DirectDraw documentation. As you should always do when checking texture-related device capabilities, be sure to verify the supported texture pixel formats by calling the IDirect3DDevice7::EnumTextureFormats method.
To prepare a palettized texture
Note If you create a palettized texture surface, but neglect to attach a palette, your application will cause an access violation within Direct3D Immediate Mode during rendering.
The palettes you use with palettized textures need not be limited to color data. In some cases, devices support texture palettes that also contain alpha information. If so, DirectDraw will expose the DDPCAPS_ALPHA palette capability flag when you call the IDirectDraw7::GetCaps method—the flag is found in the dwPalCaps member of the associated DDCAPS structure. If the rendering device can perform texturing from alpha-capable palettized textures, it will expose the D3DPTEXTURECAPS_ALPHAPALETTE capability when you call IDirect3DDevice7::GetCaps. (The D3DPTEXTURECAPS_ALPHAPALETTE flag can be found in the two D3DPRIMCAPS structures contained by the D3DDEVICEDESC7 structure you pass with the call.)
Direct3D devices can support texturing from texture surfaces that use attached palettes. These types of textures are sometimes called "palettized textures." A palettized texture is a DirectDrawSurface object, created with the DDSCAPS_TEXTURE capability, that uses one of the DDPF_PALETTEINDEXEDn pixel formats (where n is 1, 2, 4, or 8). These capabilities are included in the DDSURFACEDESC2 type that you use to create a texture (and the DDPIXELFORMAT type that the description contains). Like all palettized surfaces, instead of a color, each pixel is an index into a table of values held within an attached DirectDrawPalette object. For more information about creating and using palettized surfaces, see Surfaces and Palettes in the DirectDraw documentation. As you should always do when checking texture-related device capabilities, be sure to verify the supported texture pixel formats by using Direct3DEnumPixelFormats class retrieved by the Direct3DDevice7.GetTextureFormatsEnum method.
To prepare a palettized texture
Note If you create a palettized texture surface, but neglect to attach a palette, your application will cause an access violation within Direct3D Immediate Mode during rendering.
The palettes you use with palettized textures need not be limited to color data. In some cases, devices support texture palettes that also contain alpha information. If so, DirectDraw will expose the DDPCAPS_ALPHA palette capability flag when you call the DirectDraw7.GetCaps method—the flag is found in the lPalCaps member of the associated DDCAPS type. If the rendering device can perform texturing from alpha-capable palettized textures, it will expose the D3DPTEXTURECAPS_ALPHAPALETTE capability when you call Direct3DDevice7.GetCaps. (The D3DPTEXTURECAPS_ALPHAPALETTE flag can be found in the two D3DPRIMCAPS types contained by the D3DDEVICEDESC7 type you pass with the call.)