Introduction to DirectX11+Environment Configuration

Preface

DX11 is a product of Win7, which was released in 2009 and can be said to be very ancient. So why do we still need to learn? This is to prepare for the next step of DX12.

If you are a Win10 user and have installed the Windows 10 SDK, you can jump to the link library. This section is mainly for users of Win7 and below, but I only have Win10 at hand, just to demonstrate it. The content is roughly similar.

Get SDK

You can obtain the installation package on the official website or my published resources.

Installation

During the installation process, you may encounter S1023 errors:


This is due to an error encountered during the installation of redistributable software packages. Usually, you have already installed it, just delete it. Please note that only two versions from 2010 will be deleted, as follows:


Then you can install it normally.

Project Environment Configuration

First, find your installation directory, using my installation path as an example. I installed it directly onto the D drive. Then we need its header file directory and library directory.

  • Header file directory: D: Microsoft DirectX SDK (June 2010) Include
  • Library directory: D: Microsoft DirectX SDK (June 2010) Lib x64
    Or D: Microsoft DirectX SDK (June 2010) Lib x86

Create project

Taking VS2022 as an example, create a new project and create a Windows Desktop Application, also known as a Windows desktop application




.

Right click on Solution, click on Properties, and enter Project Configuration


In VC++ Found in the directories Include Directors And Library Directories Configure to the path just found


Alternatively, you can choose to configure it in the environment variable PATH, which also has the advantage of One configuration, used everywhere . In the future, there will be no need to configure paths

.

Link Library

The final step is to link the library. Actually, we don't need a link library at the moment, just to talk about the method. For example, we need the following three static libraries:

  • D3d11. lib
  • Dxgi.lib
  • D3dcompiler. lib

Method 1

In Linker> Input> Add to Additional Dependencies


.

Method 2

We can also link libraries in the code.

#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "d3dcompiler.lib")