Microsoft DirectX 8.1 (Visual Basic)

Creating a Device

Note  All rendering devices created by a given Microsoft® Direct3D® object share the same physical resources. Although your application can create multiple rendering devices from a single Direct3D object, because they share the same hardware, extreme performance penalties will be incurred.

To create a Direct3D device in a Microsoft Visual Basic® application, your application must first create a Direct3D object, as explained in Direct3D Object.

First, initialize values for the D3DPRESENT_PARAMETERS type that is used to create the Direct3D device. The following code example specifies a windowed application where the back buffer is flipped to the front buffer on VSYNC only.

Dim d3dDevice As Direct3DDevice8

    Dim d3dpp As D3DPRESENT_PARAMETERS

    d3dpp.Windowed = 1
    d3dpp.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC

Next, create the Direct3D device. The following Direct3D8.CreateDevice call specifies the default adapter, a hardware abstraction layer (HAL) device, and software vertex processing.

    Set d3dDevice = g_D3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, _
                                      D3DCREATE_SOFTWARE_VERTEXPROCESSING, d3dpp)
    If d3dDevice Is Nothing Then Exit Function
    

After creating the device, set its state.