Tenth chapter Project Setup and Window initialization
This chapter focuses on the basics needed to build a rendering engine. This includes creating a Visual Studio project, implementing a game loop, and eventually displaying a window on the monitor.
A New Beginning
This chapter formally begins to explain C + + programming (in this book, use C + + to focus on the DirectX API section), it is important not to expect to quickly learn to render some scenes to the screen. To put it simply, it takes a while to learn these things. First it takes time to build up some basic frameworks, and the benefits of doing so are reflected in the reuse of code in multiple projects. If you prefer to use the existing code in the companion website of this book, and skip some chapters directly to start the actual rendering work, you can also. However, if you are interested in how the underlying system framework is developed, you will find the content in the next few chapters useful.
In addition, learning the contents of these chapters requires that you are already familiar with C + + programming and Visual Studio use, but you do not need to be proficient in writing Windows applications. So you'll start by explaining the setup of the project, so that in the later chapters you'll be able to do the project yourself.
Projet Setup
The next few chapters of the rendering engine to be developed are divided into two Visual Studio projects, including a library project and a game project. The library project contains commonly used code for any number of games or rendering applications. The game project is the code that contains the specific application.
Directory Structure
It is a good idea to create a directory structure for all the projects. Table 10.1 lists the directory structure of the companion code for this book.
Table 10.1 Project Directory Structure
Project creation
To use this directory structure, first create an empty Visual Studio solution (Visual Studio Solution) in the build directory. Then right click on the solution in Solution Explorer anel and select add-->new Projecton the pop-up menu to start ADD New Project Wizard (New Project Wizard).
As shown in Figure 10.1, select the Win32 project template and fill in the Namt and location options for the project.
Figure 10.1 The Visual Studio 2013 Add New Project Wizard. Select OK to start the Win32 application Wizard (Win32 Application Settings Wizard). For the Library project, the application type item selects the static library,additional options empty Project (as shown in Figure 10.2). In the settings shown in Figure 10.2, the precompiled headers is disabled, and if you want to use precompiled headers to increase the compilation speed, you only need to check this option.
Figure 10.2 The Visual Studio 2013 WIN32 application Wizard.
Perform the same steps again to create a game project, but select the Windows Applicaiton entry in application type.
Project Build Order
Next, set the correct compilation order, right-click solution or one of the project in the Solution Explorer panel, and select Project Dependenciesin the pop-up menu. You should set the library project to game project dependencies so that the configuration can compile library project before compiling game project (as shown in Figure 10.3).