locked
How to query screen refresh rate ?

    Question

  • Hi there,

    Is there a way to determine the screen refresh rate for a direct X windows 8 app ?
    If so i could not find it so far.


    After creating the SwapChain via CreateSwapChainForCoreWindow

    I use IDXGISwapChain1 GetDesc to retrieve the DXGI_SWAP_CHAIN_DESC.

    RefreshRate in BufferDesc returns a Numerator of 0, and Denominator is 1. 


    So this is not helpful :(

    I also tried GetFullScreenDesc but this methods returns an error, so i guess its 
    just meant for desktop apps creating swapchains via CreateSwapChainForHWND.


    Thanks in advance.



    Roman Pfneudl CEO - vertex4 entertainment ltd.

    Monday, December 2, 2013 1:27 PM

All replies

  • I'll ask our DirectX expert to chime in on this.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, December 5, 2013 8:17 PM
    Moderator
  • Hello,

    Try using "IDXGIOutput::GetDisplayModeList" by calling "IDXGISwapChain::GetContainingOutput". "DXGI_MODE_DESC" has a member "RefreshRate".

    IDXGIOutput interface
    http://msdn.microsoft.com/en-us/library/windows/desktop/bb174546(v=vs.85).aspx

    DXGI_MODE_DESC structure
    http://msdn.microsoft.com/en-us/library/windows/desktop/bb173064(v=vs.85).aspx

    I hope this helps,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Friday, December 6, 2013 1:29 AM
    Moderator
  • Hi James, hi Matt, 

    Thank you, but I fear this is not what i need.
    I use CreateSwapChainForCoreWindow without setting any DisplayModes in advance. So I
    basically overtake the current screen setting. (which is probably the MS-preferred way)
    .

    I could query the available Displaymodes alright, but still i can't say which of these is the one in use right now.

    So the only thing i can think of given the given methods is:

    CreateSwapChainForCoreWindow -> GetContainingOutput -> GetDesc1 (which contains a Refresh Rate of 0/1)

    Any ideas ?

    Kind regs,
    Roman


    Roman Pfneudl CEO - vertex4 entertainment ltd.


    • Edited by v4corg Sunday, December 8, 2013 10:54 PM
    Sunday, December 8, 2013 10:49 PM
  • Maybe I'm missing something but GetRestrictToOutput should give you a IDXGIOutput that you can use.

    -James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Saturday, December 14, 2013 1:15 AM
    Moderator
  • Nope - getting a nullptr here (which seems fine because i create the swapchain without an explicit output).

    hRes = pDXGIFactory->CreateSwapChainForCoreWindow(
                    pDevice,
    		reinterpret_cast<IUnknown*>(vpWindow),
                    &swapChainDesc,
                    nullptr,	// allow on all displays
                    ppSwapChain
    				);


    Roman Pfneudl CEO - vertex4 entertainment ltd.

    Saturday, December 14, 2013 3:29 AM