Microsoft DirectX 8.1 (C++) |
This section provides information about considerations specific to compiling Microsoft® DirectX® applications. DirectX 8.1 supports only Microsoft Visual C++ 5.0 SP3 and later.
The samples included in this SDK use Microsoft® Visual C++® 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 Microsoft DirectX® samples and the DirectX applications that you create.
After opening a project file in Visual C++, verify some settings before compiling the application. The following descriptions are valid for Visual C++ 5 and 6.
Note The following discussion uses the default installation paths, C:\Dxsdk\Include and C:\Dxsdk\Lib, to describe file locations. Your installation paths might differ.
Be sure that the search path for header files is correct and the directory for DirectX header files is the first path that the compiler searches. To check the include path, choose Options from the Tools menu and 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. Choose Options from the Tools menu and 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.
For backward compatibility with earlier versions of Microsoft® DirectX®, some DirectX components include variable 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, D3D8.h, is shown here.
#ifndef DIRECT3D_VERSION #define DIRECT3D_VERSION 0x0800 #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 D3D, define DIRECT3D_VERSION to be 0x0700.
Direct3D uses globally unique identifiers, or GUIDs, to identify parts of the interface. When you use the 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 version 8.x 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 (simply IID_IDirect3D).