Language: | C++ |
Category: | Multimedia |
Date: | 2008-08-26 |
Author: | Michael Flenov |
Before you can start developing graphics application using Visual Studio, you have toinstall the DirectX Software Development Kit (DirectX SDK). The standard Visual Studio development environment has no idea about DirectX functions, thus, it must be told about them. This is done with the help of the .h header and .lib library files, which must be installed with the SDK.
You should have no difficulties installing the DirectX SDK, as all you must do it by running the installation program, accept the licensing agreement, and just keep clicking the Next button till the end of the installation process. The only thing that you must pay attention to is the directory, into which the SDK installs.
Installing SDK is not enough. It is only copies the necessary files to the computer. The development environment must be told where to look for these files. The configuration process is considered on the example os Visual Studio .NET. Launch the Visual Studio IDE and select Tools | Options menu item. This will open a configuration window. The left pane of the window contains the tree of the configuration sections. Selecting the Visual C++ Directories in the Project section will display the configuration directories in the right pane:
For notices: Specify the directory containing the header (the .h extension) files. During the installation of the DirectX SDK, they are copied into the /Include folder of the SDK root folder. In the Show directories for dropdown list, select the Include files item. Now click the New line button or press the Ctrl+Ins key combination. This will create a blank entry in the folder list. Click the three-dot button to the right of the new entry, and in the Replace Directory window select the folder containing the header files.
Next, specify for folder containing the library (the .lib extension) files. During the installation of the DirectX SDK, these are copied into the \lib folder of the SDK root folder. In the Show directories for dropdown list, select the Library files item. Add a new line as you did for header files and select the folder with the library files.
Now Visual Studio can compile projects, but it will not be able build executable files. For each DirectX project, the necessary libraries must be specified exactly. To learn how to specify library projects, create a new Win32 project using the Win32 Project Template, and execute the Project|Properties menu sequence. (Don't be confused by the Properties menu item being preceded by the name of your project.) This will open a project configuration window, similar to the environment configuration window. The left pane of the window also contains a tree of the configuration properties sections.
Selecting the Configuration Properties | Linker | Input section in the properties tree opens in the right pane the parameters window:
The libraries that must be included during the project build are specified in the Additional Dependencies line. Select this line and click the three-dot button to the right of it. This will open an Additional Dependencies window, in which the necessary libraries can be specified:
Most project using Direct 3D requires at least the d3dx9.lib and d3d9.lib libraries. Type each of these names on a separate line in the upper pane of the Additional dependencies window, and click the OK button to save the changes.
The libraries must be added for both the Release and Debug configurations. Select each configuration in the Configuration dropdown list and add the necessary libraries. In addition, for both configurations select the Configuration properties | C/C++ | Precompiled Header section in the left pane and set the Create | Use precompiled Header parameter in the right pane to the Automatically Generate (/YX) value.
Remember that the paths to the /Include and /Lib folders are specified only once in the Visual Studio properties but that the libraries in the project properties are specified for each new project.
New the Visual Studio development environment knows where to find the header and library files and the linker knows, which additional libraries must be used when building the project.