Microsoft DirectX 8.1 (C++)

Direct3D Object

Microsoft® Direct3D® is implemented through COM objects and interfaces. Applications written in C++ access these interfaces and objects directly, whereas Microsoft Visual Basic® applications interact with a layer of code—visible as the Microsoft DirectX® for Visual Basic Classes—that marshals data from a Visual Basic application to the DirectX run time.

The Direct3D object is the first object that your application creates and the last object that your application releases. Functions for enumerating and retrieving capabilities of a Direct3D device are accessible through the Direct3D object. This enables applications to select devices without creating them.

When a Microsoft® Direct3D® application written in C++ starts, it must obtain a pointer to an IDirect3D8 interface to access Direct3D functionality.

The following code example shows how to use the Direct3DCreate8 function to retrieve a pointer to the Direct3D interface.

LPDIRECT3D8 g_pD3D = NULL;

    if( NULL == (g_pD3D = Direct3DCreate8(D3D_SDK_VERSION)))
        return E_FAIL;

To navigate from the Direct3DDevice object to the Direct3D object that created the device, use the IDirect3DDevice8::GetDirect3D method.