DirectX Forum FAQ #2 [flip]

Source: Internet
Author: User
Tags pixel coloring

GameDev. Net DirectX Forum FAQ #2

 

[Introduction] This article is translated from the question frequently asked by many water friends in the DirectX area of GameDev. Net on the GameDev. Net Forum written by a water friend named jhoxley. In view of the speed of DX update, and the writing time of this article is relatively early, some parts of this article may not be applicable to new sdks. However, for new users (such as me) who are familiar with DirectX programming, many concepts are clearly described and worth looking. Therefore, the main part (mainly D3D) is translated here for reference. If you are interested and want to reprint it, please indicate the source. Thank you.

 

Http://members.gamedev.net/jhoxley/directx/DirectXForumFAQ.htm#D3D_2

 

 

Where should I start learning D3D? Since each person's starting point is very different, their learning methods will not be the same-hope this FAQ can help

You can find the most appropriate information in the following content]> combine your learning materials. Although Direct3D has many technical fields, these technologies can be divided into two aspects: theory and practice. In computer graphics, mathematical knowledge (linear algebra), as an important basic component, is widely used in graphic processing and operations, therefore, it is important to understand the concepts of vector, matrix, plane, and coordinate system. Although the D3DX API simplifies the details of these underlying mathematical knowledge, using the D3DX API can help us understand what is happening in the current scenario and why we need to use these mathematical methods at this time. If you think your mathematical skills are not that good, or you cannot remember the last time you attended the math class, pick up the math textbook again, you must spend this time learning mathematics again. <Mathematics for 3D Game Programming and Computer Graphics, 2nd Edition> written by Eric Lengyel is a good choice. This book covers a lot of mathematical knowledge about Computer Graphics and is easy to understand. First of all, we must realize that Direct3D is a complex set of APIs that are hard to grasp. It takes a lot of time and effort to grasp it to a certain level, to write high-quality and stable graphics applications. Every time we are attracted by old and current commercial games, we feel that it is easy to develop such a game-the tragedy is that it is not that simple! Keep in mind-do not want to run as long as you have not learned it. You must step by step to give yourself a good position. You must realize that it takes a lot of time to build your own knowledge, ability, and experience system step by step. As described in "how to get started" (untranslated), you must first download and configure the DirectX SDK, your development environment, and the compiler. This FAQ assumes that you are ready for these preparations. First, familiarize yourself with the content of the DirectX SDK: 1. you can find these help documents in the system SDK Start Menu. If not, go directly to % DXSDK_DIR % \ Documentation, you can also find these help documents here. The help documentation is divided into two types: "hosted DirectX" (directx9_m.chm) and "native DirectX" (directx9_c.chm). The latter is better-even if you are using it.. Of course, the APIs are essentially the same, but you only use different methods. The document does not play a query role. These help files can be divided into two parts: programming guide and reference. At the beginning, you may use more "programming guide", but when you have more experience, it is more common to use the "Reference" that can jump to the topic. 2. The example browser can be found in the SDK Start Menu. If not, % DXSDK_DIR % \ Samples \ SampleBrowser \ SampleBrowser.exe will be opened. This tool is mainly used to view sample code and articles published with the SDK. The example browser is easy to use. You need to spend some time running these different examples to see what Direct3D can do. Click the "Install Project" link of these examples in the browser to Install a copy of these examples, so that you can modify these copies without damaging the original code. The "Install Project" in the DirectX SDK is equivalent to the outdated "App Wizard" templates built in Visual Studio. 3. the DirectX SDK contains a series of tutorials. net (% DXSDK_DIR % \ Samples \ Managed \ Direct3D \ Tutorials) and C/C ++ (% DXSDK_DIR % \ Samples \ C ++ \ Direct3D \ Tutorials) development. 4. the source code for the example with the SDK release mainly appears as an example. In order to better understand all aspects of the API, in addition to the previous tutorials, these examples can provide you with essential help. Note that these examples are device-independent (IHV-neutral); although they can take advantage of hardware features as much as possible, they are not particularly optimized for a specific hardware. There is a little difference between them. If you look at ATI's Radeon SDK and Nvidia SDK, it is found that they use more or less different useful optimization methods when using advanced API features. You can run these examples in the sample browser or in the % DXSDK_DIR % \ Samples \ directory. All content in the SDK is free of charge. Before you can develop an application independently, you should spend some time learning your own resources in the SDK. If you have used the SDK, you can search for related content online. Many websites provide free Direct3D programming tutorials, examples, and useful information. The quality of these materials is uneven, but since they are free of charge, you may wish to read them. You can find more recommended websites in the "tutorials and articles" list. Of course, books are the only way to learn a new API-generally, technical books in your local bookstore won't have too many defects. GameDev. Net provides a list of recommended DirectX books. However, one thing to remember is that the DirectX SDK is updated very quickly-a new SDK will be updated every two months, if you use the books directly (or use the CD code attached to the books for compilation) in the new SDK, problems may occur. We strongly recommend Frank Luna's <Introduction to 3D Game Programming with DirectX 9> (the new version is renamed as <Introduction to 3D Game Programming with DirectX 9.0c: A Shader Approach> ), you can also find many interesting things on this book's website. So far, this FAQ has covered a lot of available resources; however, it will be helpful for learning APIs. First, Direct3D is not just a 3D API (although it seems like this in terms of name) -- You can also use it for 2D rendering (see D3D #3. I only want to make 2D images ...). Many people find that using these Apis will easily Complete 2D graphics work-you can still use a large number of important 3D APIs to complete your work without entering the 3D world. Second, Direct3D development has two features: "fixed Pipeline" and "programmable Pipeline ". The former is more traditional-by calling different State setting methods, you can notify the API to complete the desired results; the latter gives you more freedom to compile shorter programs (shader) run by the GPU ). Fixed pipelines are simple but outdated-basically only for outdated hardware (especially D3D8)-they are not a good choice for future development. If you are learning DirectX now, you 'd better avoid learning this outdated thing, instead, you should learn the programmable pipeline-although it may be more difficult to learn at the beginning (the versions earlier than D3D10 were both used in combination), it is more conducive to your learning in the long run. This is not only because Direct3D 10 has abandoned outdated fixed pipelines, but also because shaders has more powerful functions, they occupy almost all types of modern documents/Research Reports/articles/sample code, and over time it will become increasingly difficult to find outdated technology-related information. In the long run, it is very important to focus the attention of programming on the Shader written through HLSL (High Level shader Language) to learn D3D APIs, these shader are built under the effects framework (which is convenient but not necessary. More discussions on fixed and programmable pipelines will be covered in the following FAQ. Finally, there is an article in the forum named "Your moderator needs your help: How did * you * start learning Direct3D? "Post, used to discuss the FAQ in this article. In this post, you can find answers to other questions about "where to start learning D3D.

D3D #2 fixed pipeline? Programmable pipeline?

 

There are two basic ways to generate images using Direct3D: the traditional "Fixed Pipeline" (Fixed Function) or a more flexible "Programmable Pipeline" (Programmable Piplline ). Fixed pipelines are regarded as outdated methods, which are more effective in the support of earlier versions of Direct3D 8. However, in Direct3D 10, fixed pipelines are no longer available.

 

The most notable characteristic of a fixed pipeline is matrix transformation and illumination. For example, the SetTransform (), SetLight (), LightEnable (), and SetTextureStageState () functions only appear in the fixed pipeline. In addition, the fixed pipeline uses FVF ("Fiexible Vertex Format") to describe Vertex information.

 

The programmable pipeline uses vertex, geometry (New in Direct3D 10), and pixel coloring devices (pixel, by the time DX11 was released, other coloring devices were added ). These simple applets can run custom functions to process input data. In essence, this means that programming is more flexible, and compared with fixed pipelines, they can display more complex graphic effects. Programmable pipelines generally use functions such as SetPixelShader (), SetVertextShader (), and SetVertexDeclaration.

 

Although the two methods have some unique characteristics, they have almost no difference in performance. From the perspective of software development, we certainly do not want to use different programming methods to cause performance loss. Although the implementation details of hardware and drivers are confidential to the public, it is widely agreed that the graphics card driver will convert API commands into GPU-specific "micro-code" (micro-code) -- that is to say, the video card will complete all practical work, regardless of whether the code is based on a fixed pipeline or a programmable pipeline.

 

Direct3D 10 has abandoned the fixed pipeline, which means that Microsoft wants developers to focus on Shader-based models, whether to be compatible with existing programs or for future development. Considering the complexity of the Shader and the fact that a large number of Code are currently using the fixed pipeline mode, it is difficult to achieve the above objectives, but at least we have another effective method to try. The [Effects Framework] of Direct3D 9 allows you to unify fixed pipelines and Shader-based code, so that the Host Program does not need to focus much on which technology we are using. The abstract concept of performance framework allows us to use a fixed pipeline to implement software functions and replace them with the corresponding shaders when necessary in the future.

 

Series D3D #1Where should I start learning D3D?

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.