Partager via


Selecting a Device (Windows CE 5.0)

Send Feedback

Applications can query hardware to detect the supported Microsoft® Direct3D® Mobile device types. This section contains information on the primary tasks involved in enumerating display adapters and selecting Direct3D Mobile devices.

An application must perform a series of tasks to select an appropriate Direct3D Mobile device. Note that the following steps are intended for a full-screen application. In most cases, a windowed application can skip most of these steps.

  1. If required, the application checks for the presence of hardware acceleration in each enumerated display mode by calling IDirect3DMobile::CheckDeviceType, as shown in the following code example. Note that this is only one of the possible uses for CheckDeviceType; for details, see Determining Hardware Support.

    D3DMPRESENT_PARAMETERS Params;
    // Initialize values for D3DMPRESENT_PARAMETERS members. 
    
    Params.BackBufferFormat = D3DMFMT_X1R5G5B5; 
    
    if(FAILED(m_pD3DM->CheckDeviceType(Device.m_uAdapter, 
                                       Device.m_DevType, 
                                       Params.BackBufferFormat,
                                       Params.BackBufferFormat, 
                                       FALSE))) 
      return E_FAIL;
    
  2. The application checks for the desired level of functionality for the device on this adapter by calling the IDirect3DMobile::GetDeviceCaps method. This method filters out those devices that do not support the required functionality. The device capability returned by GetDeviceCaps is guaranteed to be constant for a device across all display modes verified by CheckDeviceType.

  3. Devices can always render to surfaces of the format of an enumerated display mode that is supported by the device. If the application is required to render to a surface of a different format, it can call IDirect3DMobile::CheckDeviceFormat. If the device can render to the format, then it is guaranteed that all capabilities returned by GetDeviceCaps are applicable.

  4. Lastly, the application can determine if multisampling techniques are supported for a render format by using the IDirect3DMobile::CheckDeviceMultiSampleType method.

After completing the above steps, the application should have a list of display modes in which it can operate. The final step is to verify that enough device-accessible memory is available to accommodate the required number of buffers. This test is necessary because the memory consumption for the mode and multisample combination is impossible to predict without verifying it. Moreover, some display adapter architectures might not have a constant amount of device-accessible memory. This means that an application should be able to report out-of-video-memory failures when going into full-screen mode. Typically, an application should remove full-screen mode from the list of modes it offers to a user, or it should attempt to consume less memory by reducing the number of back buffers or using a less expensive multisampling technique.

A windowed application performs a similar set of tasks.

  1. It determines the desktop rectangle covered by the client area of the window.

  2. It enumerates adapters, looking for the adapter whose monitor covers the client area. If the client area is owned by more than one adapter, then the application can choose to drive each adapter independently, or to drive a single adapter and have Direct3D transfer pixels from one device to another at presentation. The application can also disregard the above two steps and use the D3DMADAPTER_DEFAULT adapter. Note that this might result in slower operation when the window is placed on a secondary monitor.

  3. The application should call CheckDeviceType to determine if the device can support rendering to a back buffer of the specified format while in desktop mode. IDirect3DMobile::GetAdapterDisplayMode can be used to determine the desktop display format, as shown in the following code example.

    D3DMPRESENT_PARAMETERS Params;
    // Initialize values for D3DMPRESENT_PARAMETERS members. 
    
    // Use the current display mode.
    D3DMDISPLAYMODE mode;
    
    if(FAILED(m_pD3DM->GetAdapterDisplayMode(Device.m_uAdapter , &mode)))
            return E_FAIL;
    
    Params.BackBufferFormat = mode.Format;
    
    if(FAILED(m_pD3DM->CheckDeviceType(Device.m_uAdapter,
                                       Device.m_DevType,
                                       Params.BackBufferFormat,
                                       Params.BackBufferFormat,
                                       FALSE)))
           return E_FAIL;
    

See Also

Using Devices

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.