VC怎样判断Direct3D加速是否开启?

解决方案 »

  1.   

    d3d = Direct3DCreate9(D3D_SDK_VERSION);    // create the Direct3D interfaceD3DPRESENT_PARAMETERS d3dpp;    // create a struct to hold various device informationZeroMemory(&d3dpp, sizeof(d3dpp));    // clear out the struct for use
    d3dpp.Windowed = TRUE;    // program windowed, not fullscreen
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;    // discard old frames
    d3dpp.hDeviceWindow = hWnd;    // set the window to be used by Direct3D // create a device class using this information and information from the d3dpp stuct
     d3d->CreateDevice(D3DADAPTER_DEFAULT,
                       D3DDEVTYPE_HAL,
                       hWnd,
                       D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                       &d3dpp,
                       &d3ddev);
    是不是CreateDevice()成功执行就代表3D加速已经启用了?
      

  2.   

    是的,几个关键的参数是
    D3DADAPTER_DEFAULT
    D3DDEVTYPE_HAL
    如果你指定 HAL 的 Device 而 D3D 没有发现机器上有硬件则返回失败