The image file formats supported by Direct3D are:
Joint Image Expert Group (. jpg)
Windows Bitmap (. bmp)
Raster image file Storage format (. TGA)
Portable Network Image File format (. png)
Direct drawing Surface format (. DDS)
Portable pixel mapping format (. ppm)
Windows device-independent bitmap format (. dib)
High dynamic range format (. hdr)
Portable floating-point mapping Format (. PFM)
Creating and using textures
A structure called lpdirect3dtexture9 is used when loading images in Direct3D. The LPDIRECT3DTEXTURE9 structure is a texture object in the Direct3D, which is used when loading a 1D or 2D texture image. Whenever you create a lpdirect3dtexture9 texture object, the release () function of the object is called to dispose of it. When you create a texture, you can choose to manually load the image data onto the object, or use the Direct3D function to load the image data from the file onto the object. This book will start with loading the image data from the file, although the reader can load the image file from any image file format supported by Direct3D, but here the main concern is that his image file format is. bmp and. TGA in both image file formats.
To create an empty texture image, the reader can use the d3dxcreatetexture () function to manually add data to the texture. Once the texture object is successfully created, the D3dxcreatetexture () function returns a D3D_OK value (other values are returned if an error occurs). If the function returns and the texture object is null (empty), then there is a problem with the texture creation. Listing 4.1 lists the prototypes of the d3dxcreatetexture () shouting slang.
Prototype of the program manifest D3dxcreatetexture () function
HRESULT WINAPI d3dxcreatetexture (
lpdirect3ddevice9 pdevice, //Direct3D9 Device Object
UINT width,// image width
UINT Height,// image height
uint miplevels, //Picture layer, general with D3dx_default, with image quality for
DWORD usage, // Set how this texture is used
d3dformat Format, //number of bits per color component
D3dpool Pool, //Memory category
where texture objects reside LPDIRECT3DTEXTURE9 * Pptexture //points to the newly created texture object
);