Direct3D9 primary tutorial

zhaozj2021-02-16  60

Preface:

This tutorial is prepared for beginners, as long as it will make simple VC programming and a basic knowledge of a three-dimensional geometry. With it, you can learn about Direct3D's basic concepts, learn to draw simple geometric graphics and master the basic usage of light source, material, and texture.

The substance of 3D drawing is to create three-dimensional illusion on the 2D computer screen, to use some mathematical transformation to model and process geometric graphics. I will explain these transformations and their usage as much as possible, avoiding complex mathematical knowledge.

1 development environment

This article uses VC 6.0 to do locale, it is recommended to install Service Pack5 patch packages. In order to create a Direct3D program, you need to download the DirectX SDK from the Microsoft website. I use the latest version 9.0, about 200 megabytes, URL http://www.microsoft.com/downloads/. After the SDK is installed, the development environment is built. Of course, to run compilation programs, DirectX9 is essential (Microsoft has already included DirectX9 installation files in the SDK).

DirectX9 SDK provides a program wizard for VC users, which can easily generate "empty" Direct3D programs. However, in order to facilitate the reader to master the basics of Direct3D programming, this article will be in the MFC single document program (SDI) as a framework, add Direct3D drawing.

2 use COM components

DirectX features are provided in the form of COM components. COM is a short written by component object model, which is an agreement to implement binary connections between software modules. When this connection is established, the two modules can be communicated by a mechanism called an "interface". Our common ActiveX control is a COM component.

The details of COM are quite complicated, and you can write a thick monograph. But don't worry, Microsoft has simplified COM for us to maximize COM, even if you can't do it, it doesn't matter. As a Direct3D developer, just understand the interface and its usage: the so-called interface, is actually a set of special C objects, the application accesses the COM component by calling the member functions of these objects, to implement the functionality of the component. In COM terminology, these member functions are called Method. Although it is called, it is called compared to ordinary C objects than normal C objects. The particularity of the interface is that its generation and destruction are completed by the system without user intervention.

In Direct3D programming, the work we have to do is basically summarized as:

Call the appropriate function to get the interface pointer;

Call the method of the interface (member function) to complete the desired function;

After using the interface, call the Release method to "release", pay attention to the order of the release should be opposite to the order of obtaining them.

3 First Program - Initialization Direct3D

3.1 Creating a Program Framework

3.2 Initializing Direct3D

3.3 Rendering

3.4 Release Interface

4 draw a triangle

4.1 Some Mathematical Concepts

4.2 draw a triangle

5 draw a three-prism-index cache and Z cache

5.1 What is an index cache

5.2 Creating an index cache

5.3 Rendering the index cache

5.4 Open Z Cache

6 painting a cone - lighting and material

6.1 Basic Concept

6.2 lighting

6.3 Material

6.4 painting a cone

6.5 Gaolide coloring and flat coloring

7 is a cone added texture

7.1 Basic Concept

7.2 Creating a texture

7.3 Rendering with texture

8 Mesh model

8.1 What is a Mesh model

8.2 Draw a Mesh Model

9 display text

2D in Direct3D

11 Direct3D program structure

caution:

Because the original article is written in PDF format,

And the article is relatively long, more illustrations,

Not easy to post,

Comrade for interest, please download the full text from the address,

http://oldsong.nease.net/d3d9-pdfbook.zip

转载请注明原文地址:https://www.9cbs.com/read-22797.html

New Post(0)