DirectX - Direct3D Initialization



The initialization process of Direct3D needs to be familiar with some basic Direct3D types and graphics concepts. In this chapter, we will focus on necessary steps to initialize Direct3D.

It includes a small detour which is taken to introduce accurate timing and the required time measurements needed for real-time graphics applications.

Now let us focus on Direct3D initialization process which requires us to be familiar with certain basic graphics concepts and Direct3D types.

Overview of Direct3D

It can be described as low-level graphics API (Application programming Interface) which enables us to render 3D worlds with the help of hardware acceleration. Direct3D includes various software interfaces through which a user can control the graphics hardware.

The best illustration is to instruct the graphics hardware to clear the mentioned target with the help of Direct3D method.

The main method is given below −

ID3D11DeviceContext::ClearRenderTargetView

The Direct3D layer is defined between the application and the graphics hardware, which means there is no need for a user to worry about the specifics of the 3D hardware as long as there is capability of Direct3D 11 capable device.

A Direct3D 11 capable graphics device must support the entire Direct3D 11 capability set, with few exceptions (i.e., the multisampling count still need to be queried, as they can vary between Direct3D 11 hardware). This is in contrast to Direct3D 9, where a device only had to support a subset of Direct3D 9 capabilities. Consequently, if a Direct3D 9 application wants to use a certain feature, it is necessary to first check if the available hardware supports that feature; as calling a Direct3D function not implemented by the hardware results in failure.

In Direct3D 11, device capability checking is no longer necessary because it is now a strict requirement that a Direct3D 11 device implement the entire Direct3D 11 capability set.

COM

Component Object Model (COM) is the technology that allows DirectX to be programming language independent and have backwards compatibility. Usually a user refers COM object as an interface, which for our purposes can be thought of and used as a C++ class.

Most of the details of this model are hidden to us when programming DirectX with C++. The only thing that a user must know is that COM interfaces through special functions or by the methods of another COM interface. We do not create a COM interface with the C++ new keyword.

In addition, when we are done with an interface, we call its Release method (all COM interfaces inherit functionality from the Unknown COM interface, which provides the Release method) rather than deleting it. COM objects perform their own memory management.

There is, of course, much more to COM, but more detail is not necessary for using DirectX effectively.

Note − The DirectX API is based on the Component Object Model (COM). COM objects consist of a collection of interfaces that expose methods which developers use to access DirectX.

Advertisements