How to get current display mode (resolution, refresh rate) of a monitor/output in DXGI?

后端 未结 3 1028
野性不改
野性不改 2021-02-13 13:24

I am creating a multi-monitor full screen DXGI/D3D application. I am enumerating through the available outputs and adapters in preparation of creating their swap chains.

3条回答
  •  余生分开走
    2021-02-13 13:44

    This might be what you are looking for:
    
    
                // Get display mode list
                std::vector modeList = GetDisplayModeList(*outputItor);
                for(std::vector::iterator modeItor = modeList.begin(); modeItor != modeList.end(); ++modeItor)
                {
                //  PrintDisplayModeInfo(*modeItor);
                }
            }
    
    
    
    
    std::vector GetDisplayModeList(IDXGIOutput* output)
    {
        UINT num = 0;
        DXGI_FORMAT format = DXGI_FORMAT_R32G32B32A32_TYPELESS;
        UINT flags = DXGI_ENUM_MODES_INTERLACED | DXGI_ENUM_MODES_SCALING;
    
        // Get number of display modes
        output->GetDisplayModeList(format, flags, &num, 0);
    
        // Get display mode list
        DXGI_MODE_DESC * pDescs = new DXGI_MODE_DESC[num];
        output->GetDisplayModeList(format, flags, &num, pDescs);
    
        std::vector displayList;
        for(int i = 0; i < num; ++i)
        {
            displayList.push_back(&pDescs[i]);
        }
    
        return displayList;
    }
    

提交回复
热议问题