> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XDisplayHdrModePreference

> XDisplayHdrModePreference

# XDisplayHdrModePreference

指定呼叫 [XDisplayTryEnableHdrMode](/zh-TW/reference/system/xdisplay/functions/xdisplaytryenablehdrmode) 時要使用的偏好模式。

<a id="syntaxSection" />

## 語法

```cpp theme={null}
enum class XDisplayHdrModePreference  : uint32_t
{
    PreferHdr = 0,
    PreferRefreshRate = 1
}
```

<a id="constantsSection" />

## 常數

| 常數 | 描述 |
| - | - |
| PreferHdr | 當顯示器不支援同時使用 HDR 與較高重新整理頻率時，優先使用 HDR。 |
| PreferRefreshRate | 當顯示器不支援同時使用 HDR 與 120 Hz 重新整理頻率時，優先使用 120 Hz 重新整理頻率。 |

<a id="remarksSection" />

## 備註

如需 HDR 支援的詳細資訊，請參閱[高動態範圍 (HDR) 輸出 (NDA 主題)](/zh-TW/build/core-features/graphics/overviews/hdr-support)。

如需 HDR 亮度值和色調對應的相關資訊，請參閱 HDR Gaming Interest Group 網站上的 [For a Better HDR Gaming Experience](https://www.hgig.org/doc/ForBetterHDRGaming.pdf) 簡報。

**範例**

下列程式碼範例示範如何為連接的顯示器啟用 HDR 模式。如果傳回 [XDisplayHdrModeInfo::Enabled](/zh-TW/reference/system/xdisplay/enums/xdisplayhdrmoderesult)，表示已為顯示器啟用 HDR 模式，遊戲可以選擇使用所傳回 `XDisplayHdrModeInfo` 結構中的亮度值，針對連接之顯示器的功能來最佳化轉譯的 HDR 影像。否則，表示 HDR 模式無法使用或已停用，遊戲會以標準動態範圍 (SDR) 模式初始化。

```cpp theme={null}
void Game::InitializeHDRMode() 
{
    // Attempt to enable HDR mode, then initialize based on the 
    // result of the attempt.
    XDisplayHdrModeInfo displayModeHdrInfo;

    if (XDisplayHdrModeResult::Enabled == XDisplayTryEnableHdrMode(XDisplayHdrModePreference::PreferHdr, &displayModeHdrInfo))
    {
        // HDR mode is enabled for the attached display.
        InitializeAsHDR(
            displayModeHdrInfo.minToneMapLuminance,
            displayModeHdrInfo.maxToneMapLuminance,
            displayModeHdrInfo.maxFullFrameToneMapLuminance);
    }
    else
    {
        // Either HDR mode is disabled for the attached display, or the
        // attached display does not support HDR.
        InitializeAsSDR();
    }
}
```

<a id="requirementsSection" />

## 需求

**標頭：** XDisplay.h

**支援的平台**：Windows、XBOX One 系列主機和 XBOX Series 主機

<a id="seealsoSection" />

## 另請參閱

[XDisplayTryEnableHdrMode](/zh-TW/reference/system/xdisplay/functions/xdisplaytryenablehdrmode)\
[XDisplay](/zh-TW/reference/system/xdisplay/xdisplay_members)\
[高動態範圍 (HDR) 輸出 (NDA 主題)](/zh-TW/build/core-features/graphics/overviews/hdr-support)


## Related topics

- [XDisplayHdrModePreference](/reference/system/xdisplay/enums/xdisplayhdrmodepreference.md)
- [XDisplayTryEnableHdrMode](/reference/system/xdisplay/functions/xdisplaytryenablehdrmode.md)
