Preface:
This tutorial is intended for beginners, As long as Simple VC ++ programming and a little basic knowledge of ry. Through it, you can understand the basic concepts of direct3d, learn to draw simple geometric images, and master the basic usage of light sources, materials, and textures.
The essence of 3D plotting is to create 3D illusion on a two-dimensional computer screen. Therefore, some mathematical transformations are used to model and process geometric images. I will try to explain these transformations and their usage in easy-to-understand languages to avoid involving complex mathematical knowledge.
1Development Environment
This article uses VC ++ 6.0 as the language environment. We recommend that you install the service pack5 patch package. In order to create the direct3d program, you need to download and install the DirectX SDK from the Microsoft website, I use the latest version 9.0, about 200 MB, web site http://www.microsoft.com/downloads. After the SDK is installed, the development environment is ready. Of course, to run compiled programs, directx9 is essential (Microsoft has included the directx9 installation file in the SDK ).
The directx9 SDK provides a program wizard for VC users to conveniently generate an "empty" direct3d program. However, in order to facilitate the reader to master the basic knowledge of direct3d programming, this article will use the MFC single-document Program (SDI) as the framework to add the direct3d drawing function on it.
2Use comComponents
DirectX functions are provided in the form of COM components. Com is short for the component object model. It is a protocol used to implement binary connections between software modules. After the connection is established, the two modules can communicate with each other through an interface mechanism. Our commonly used ActiveX control is a COM component.
The implementation details of COM are quite complex. You can write a thick monograph. But don't worry. Microsoft has already simplified the use of COM to the maximum extent for us, even if you know nothing about com. As a direct3d developer, you only need to understand the interface and its usage. The so-called interface is actually a special set of C ++ objects. Applications call member functions of these objects, to access the COM component. In COM terminology, these member functions are called methods ). Although the name has changed, its calling syntax is no different from that of a common C ++ object. An interface is generated and destroyed by the system without user intervention.
In direct3d programming, we can basically do the following work:
Call an appropriate function to obtain the interface pointer;
Call the interface method (member function) to complete the required functions;
After the interface is used up, call the release method to "release". Note that the order of release should be the opposite of the order in which they are obtained.
3 first program-Initialize direct3d
3.1 create a program framework
3.2 initialize direct3d
3.3 Rendering
3.4 Release Interface
4. Draw a triangle
4.1 mathematical concepts
Draw a triangle at 4.2
5. Draw a triangular pyramid-index cache and Z Cache
5.1 What is index Cache
5.2 create index Cache
5.3 rendering index Cache
5.4 enable Z Cache
6. Draw a cone-light and material
6.1 Basic Concepts
6.2 Lighting
6.3 Material
6.4 draw a cone
6.5 High Lord coloring and plane coloring
7. Add a texture for the cone
7.1 Basic Concepts
7.2 create a texture
7.3 texture Rendering
8 Mesh Model
8.1 what is a mesh model
8.2 draw a mesh model
9 display text
10 2D in direct3d
11 direct3d program structure
Note:
Because the original article was written in PDF format,
The article is long and has many illustrations,
Not easy to paste,
If you are interested, download the full text from the following address,
Http://oldsong.nease.net/d3d9-pdfbook.zip