?/TD> |
Microsoft DirectX 9.0 |
This section provides information about considerations specific to compiling Microsoft?DirectX?applications. DirectX 9.0 supports only Microsoft Visual C++?6.0 and later.
The samples included in this software development kit (SDK) use Microsoft Visual Studio?project files (.dsp files) that describe the appropriate source files, project resources, and linker settings for each sample. However, you might need to make additional preparations to ensure that the samples compile and link properly, or you might need to prepare settings for a new project. The information provided here applies to the DirectX samples and the DirectX applications that you create.
After opening a project file in Visual Studio, verify some settings before compiling the application. The settings will depend on whether you are using Visual C++ 6.0 or Visual Studio .NET.
Be sure that the search path for header files is correct and that the directory for DirectX header files is the first path that the compiler searches. To check the include path, from the Tools menu, choose Options and then select the Directories tab. The following dialog box will appear.
The topmost path indicates the folder that contains the latest DirectX header files. The default path is C:\DXSDK\Include. If the path is not present, add it to the list and move it to the top of the search list by using the toolbar controls within the Directories tab.
Check the search paths and search order that the linker uses to search for link libraries. The link search paths are also listed on the Directories tab. From the Tools menu, choose Options and then select the Directories tab. When the dialog box appears, choose the Library Files option in the Show directories for list box. The topmost path should be the folder that contains the latest DirectX link libraries. The default path is C:\DXSDK\Lib.
If you are using the provided sample project files, you do not need to verify these settings. They are specified with the project files. For new applications, on the Project menu, click Settings. The following dialog box appears.
You should verify that the application is linked to the appropriate standard DirectX link libraries.
Be sure that the search path for header files is correct and that the directory for DirectX header files is the first path that the compiler searches. To check the include path, from the Tools menu, choose Options, then open the Projects folder and select VC++ Directories. The following window will appear.
The topmost path indicates the folder that contains the latest DirectX header files. The default path is C:\DXSDK\Include. If the path is not present, add it to the list and move it to the top of the search list by using the up and down arrow buttons within the window.
Check the search paths and search order that the linker uses to search for link libraries. The link search paths are also listed in the window displaying the VC++ Directories information. From the Tools menu, choose Options, then open the Projects folder and select VC++ Directories. When the window appears, choose the Library Files option in the Show directories for list box. The topmost path should be the folder that contains the latest DirectX link libraries. The default path is C:\DXSDK\Lib.
If you are using the provided sample project files, you do not need to verify these settings. They are specified with the project files. For new applications, on the Project menu, click Properties. Open the Linker folder and select Input. The following dialog box appears.
You should verify that libraries listed in the Application Dependencies are the appropriate standard DirectX link libraries.
For backward compatibility with earlier versions of DirectX, some DirectX components include variable application programming interface (API) element definitions in their header files. Affected elements are typically capability structures or flag sets that are version specific. Parts of some header files are surrounded by preprocessor conditionals that cause the preprocessor to filter out unneeded definitions. The value of the defined constant identifies a specific version of the component. If no value is defined, the headers set a value that identifies the DirectX version for which the header file was written. An example from the Microsoft Direct3D?header file, D3D9.h, is shown here.
#ifndef DIRECT3D_VERSION #define DIRECT3D_VERSION 0x0900 #endif //DIRECT3D_VERSION
You can define other values for these constants to use newer versions of the header files with older versions of the components. For example, to use the latest headers to compile against the DirectX 7.0 version of Direct3D, define DIRECT3D_VERSION to be 0x0700.
Direct3D uses globally unique identifiers (GUIDs) to identify parts of the interface. When you use the IUnknown::QueryInterface method to determine whether an object supports an interface, you identify the interface you're interested in by using its GUID.
To use GUIDs in a DirectX 9.0 application, include a link to the Dxguid.lib library and remove "#define INITGUID" from all your header files and source files. This is a change from previous versions, where GUIDs were linked by defining INITGUID prior to all other include and define statements. In the older versions, INITGUID needed to be defined in only one of your source modules.
Note that you use GUIDs differently depending on whether your application is written in C or C++. In C, you pass a pointer to the GUID (&IID_IDirect3D, for example), but in C++, you pass a reference to it (IID_IDirect3D).