Take creating a texture quadrilateral as an example to record how to map the texture of a quadrilateral and how to set the texture filter. If our hardware supports multi-level progressive texture ing, in the program, you can use the d3dxcreatetexturefromfile function to automatically create a multi-level progressive texture chain.
The general steps are as follows:
(1) construct the vertex that makes up the object and specify the texture coordinates for it.
(2) Use the d3dxcreatetexturefromfile function to load a texture for the idirect3dtexture9 interface.
(3) set the zoom filter, zoom filter, and multi-level progressive texture filter.
(4) Before drawing an object, use the function idirect3ddevice9: settexture to set the texture associated with the object.
First, you need to initialize several global variables, one for storing the vertex cache of the Quadrilateral vertex, and the other for ing to the texture of the Quadrilateral.
In the setup function, we define two triangles with vertex texture coordinates as before to construct a quadrilateral. Then, load the bitmap file for the idirect3dtexture9 interface. It is best to use a relative address. The loading mode is similar to the loadpicture mode of VB, but there are two additional parameters. Next, call the settexture method to enable the texture. Finally, we set the zoom filter and zoom filter to linear filter mode, and the progressive texture filter to d3dtexf_point. Of course, the filter mode can be freely selected, mainly for efficiency.
Now we can draw the Quadrilateral in the display function as usual, and we can map the current texture to the Quadrilateral surface.