Procedure for creating a texture ing using DirectX

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.