Concept is the key words that people summarize and refine in order to describe an objective thing accurately. Such as the most basic concepts in mathematics: point, line, plane, function… “, “particle” in physics, etc. When we used to learn these knowledge, in fact, the most important thing is to establish an accurate understanding of these concepts, and only when most people reach a consensus on these universally applicable concepts can the discipline be established.

Students often get questions wrong, and the most common reason is that they don’t understand the concepts.

In D3D learning, there are the following concepts to master and understand.

D3D is a set of low-level graphics API, essentially speaking, or software interface, we control the graphics hardware through these series of interfaces, for the actual computer applications to achieve graphics, three-dimensional graphics modeling applications to provide methods.

Apply colours to a drawing

Friends who have just entered the industry may not understand this word deeply enough, often “what kind of atmosphere has been rendered by XXX in the film”, and so on. So it gives you a vague sense of what happens when the term render is used in computer graphics. Simply speaking, the rendering mentioned here is the process of displaying all kinds of pictures and graphic data that have been calculated and prepared by the program in the display according to the requirements of two-dimensional position, three-position and light condition.

Rendering process: data that has been prepared (can be images, can be YUV data, but RGB data, can also be audio, etc., this step is not the start of rendering)

  1. There is nothing to be said for creating D3D resources and devices. Call the interface provided by D3D and pass in the corresponding parameters. Take D3D9 as an example:
Direct3DCreate9(a);// Get COM programming interface IDirect3D9
IDirect3D9->CreateDevice(a); Create the Device using IDirect3D9.Copy the code

COM description Component Object Model (COM) technology makes DirectX independent of any programming language and has version-backward compatibility features. We often refer to COM objects as interfaces and use them as a normal C++ class.

  1. Determine the coordinates Both 2 d and 3 d scene, we need to show data in what parts of the screen, this is the chief according to the need to set, 2 d is simpler, can use screen coordinates directly, to determine, but three is complex, there are four main window in the software, is divided into top view, front view, side view and perspective. Most of the time we render perspectives instead of other views, and the perspective camera follows the principles of a real camera, so that the results we see are as solid as the real 3d world. The coordinate system in D3D is divided into several kinds: local coordinate system, world coordinate system, observation coordinate system and projection worksheet. These coordinate system is how we describe a three-dimensional graph in the two-dimensional computer screen from different angles. We’ll talk about that in practice. In general, the determination of coordinates is to determine where the graphics we are going to display are placed on the screen.
  2. When creating a resource rendering, the image data needs to be saved to a Surface or to a Texture. Essentially, the Surface and Texture are both blocks of memory that will store graphic data. These resources are created based on the coordinates identified in 2.
  3. Starting the drawing process is a complex process of first setting resources (vertices, texture buffers, etc.) to the device data stream, then modifying and changing the position of the view, where device data stream refers to abstract data in the 3DAPI, and finally brushing the data stream to the screen.

In short, the basic process of rendering is even so. There may be some inaccuracies in the description, but that’s basically the process, and for those of you who have never worked with D3D rendering, there is a concept that you can go through the code and come back and understand the process better.

D3D device

D3D equipment can be understood as a set of interfaces, which abstracts the parameters and resources of the graphics card, or even as an abstraction of a simple local graphics card. A device can be created using the Direct3Dcreate9() interface, and all of its interfaces can be called from the device object.

texture

Texture mapping A two-dimensional drawing or drawings showing surface details of an object. Also called texture mapping, it makes the object look more realistic when the texture is mapped to the surface in a specific way. Texture mapping is a technique that allows us to assign image data to triangles; This allowed us to be more nuanced and realistic with our scenes.

As we see to the naked eye 3 d object, the interior of the opaque objects we are invisible to the naked eye, the eye can see is just three surfaces, can d as an example of a simple understanding to the surface of the object, when we are in the system to create a 3 d cube, each of the three two-dimensional surface of the object, is that we use grain to draw.

Essentially, a texture is a specially specified chunk of memory in the system. This resource operates in a way that is different from the system’s normal memory.

triangle

In Direct3D, the concept of “triangle” often comes up. This is because in 3D graphics rendering, all objects are made up of triangles. Because a triangle can represent a plane, and 3D objects are made of one or more planes.

SwapChain

To avoid flicker in the animation, it is best to perform all animation frame drawing in an off-screen texture called the back buffer. When we finish drawing the given frame in the background buffer, we can display the background buffer as a complete frame on the screen; With this method, the user is not aware of the frame being drawn, only sees the complete frame. In theory, the time it takes to bring a frame to the screen is less than the screen’s vertical refresh time. The hardware automatically maintains two built-in texture buffers to do this, called the front buffer and the background buffer. The foreground buffer stores the image data currently displayed on the screen, while the next frame of the animation is drawn in the background buffer. When the drawing of the background buffer is complete, the roles of the two buffers are reversed: the background buffer becomes the foreground buffer, and the foreground buffer becomes the background buffer in preparation for the drawing of the next frame. We refer to the act of exchanging the functions of the front and back buffers as presenting. Commit is a fast operation because it simply swaps the pointer to the foreground buffer with the pointer to the background buffer.

DirectX level of abstraction



It’s important to know where the D3D API is in the computer system hierarchy. Analogous to the C++ programming model, the bottom layer is hardware, the next layer is assembly that can manipulate the hardware directly, and then the more advanced language C++; HAL’s (hardware abstraction layers) in the figure above can act as a “assembly” of the display hardware.

Mistakes are inevitable in this paper. With further study, I hope to continue to understand.