Direct3D9 Primary Course

Source: Internet
Author: User

Objective:

This tutorial is prepared for beginners, as long as the simple VC + + programming and a little solid geometry of the basic knowledge can be. Through it, we can learn the basic concept of Direct3D, learn to draw simple geometry, and master the basic usage of light source, material and texture.

The essence of 3D drawing is to create three-dimensional illusion on two-dimensional computer screen, which uses some mathematical transformations to model and process geometry. I will try to explain these transformations and their usage in plain language as far as possible, avoiding complicated mathematical knowledge.

1 development environment

This article chooses the VC + + 6.0 to do the language environment, recommends installs the service PACK5 fix package. In order to create the Direct3D program, need to download the installation of DirectX SDK from the Microsoft website, I use the latest version 9.0, probably more than 200 trillion, url http://www.microsoft.com/downloads/. After installing the SDK, the development environment is built. Of course, to run a compiled program, DIRECTX9 is essential (Microsoft has included DirectX9 installation files in the SDK).

The DirectX9 SDK provides VC users with a program wizard that makes it easy to generate "empty" Direct3D programs. However, in order to facilitate the reader to master the basic knowledge of Direct3D programming, this article will take the MFC Single Document program (SDI) as the framework, add Direct3D drawing function on it.

2 Using COM components

The functionality of DirectX is provided in the form of a COM component. COM is a shorthand for the Component Object model (Component object models), which is a protocol for implementing binary connections between software modules. When this connection is established, two modules can be communicated by means of a mechanism called "Interface (Interface)". Our common ActiveX control is a COM component.

COM's implementation details are quite complex, can write a thick monograph. But don't worry, Microsoft has simplified the use of COM for us, even if you are ignorant of COM. As a Direct3D developer, just understand the interface and its usage: the so-called interface, in fact, is a special set of C + + objects, the application by invoking the object's member functions, to access the COM components to achieve the functionality of the component. In COM terminology, these member functions are called methods. Although the salutation has changed, its invocation syntax is no more than the normal C + + object. 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 can basically be summed up as:

Call the appropriate function to get the interface pointer;

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

After you run out of interfaces, call the release method for "free" and note that the release order should be reversed from the order in which they were obtained.

3 First Program-initialization Direct3D

3.1 Creating a program framework

3.2 Initialization of 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 triple pyramid-index cache and Z-cache

5.1 What is an indexed cache

5.2 Creating an index cache

5.3 Render Index Cache

5.4 Open Z Cache

6 Draw a cone-light and material

6.1 Basic Concepts

6.2 Lights

6.3 Material

6.4 Draw a cone

6.5 Golod coloring and flat coloring

7 Add texture to cone

7.1 Basic Concepts

7.2 Creating textures

7.3 Rendering with textures

8 Mesh Model

8.1 What is mesh model

8.2 Drawing Mesh Model

9 Display text

2D in Direct3D

A Direct3D program Structure

Please note:

Because the original article is written in PDF format, and the article is relatively long, illustrations more, not too easy to paste, interested comrades please download the full text from the following address

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.