⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dxutenum.h

📁 声音和图片的加载功能,不过运行起来有点卡
💻 H
📖 第 1 页 / 共 2 页
字号:
// A struct describing device settings that contains a unique combination of 
// adapter format, back buffer format, and windowed that is compatible with a 
// particular Direct3D device and the app.
//--------------------------------------------------------------------------------------
struct CD3D9EnumDeviceSettingsCombo
{
    UINT AdapterOrdinal;
    D3DDEVTYPE DeviceType;
    D3DFORMAT AdapterFormat;
    D3DFORMAT BackBufferFormat;
    BOOL Windowed;

    CGrowableArray<D3DFORMAT> depthStencilFormatList; // List of D3DFORMATs
    CGrowableArray<D3DMULTISAMPLE_TYPE> multiSampleTypeList; // List of D3DMULTISAMPLE_TYPEs
    CGrowableArray<DWORD> multiSampleQualityList; // List of number of quality levels for each multisample type
    CGrowableArray<UINT> presentIntervalList; // List of D3DPRESENT flags
    CGrowableArray<CD3D9EnumDSMSConflict> DSMSConflictList; // List of CD3D9EnumDSMSConflict

    CD3D9EnumAdapterInfo* pAdapterInfo;
    CD3D9EnumDeviceInfo* pDeviceInfo;
};


//--------------------------------------------------------------------------------------
// A depth/stencil buffer format that is incompatible with a
// multisample type.
//--------------------------------------------------------------------------------------
struct CD3D9EnumDSMSConflict
{
    D3DFORMAT DSFormat;
    D3DMULTISAMPLE_TYPE MSType;
};


//--------------------------------------------------------------------------------------
// Forward declarations
//--------------------------------------------------------------------------------------
class CD3D10EnumAdapterInfo;
class CD3D10EnumDeviceInfo;
class CD3D10EnumOutputInfo;
struct CD3D10EnumDeviceSettingsCombo;


//--------------------------------------------------------------------------------------
// Enumerates available Direct3D10 adapters, devices, modes, etc.
// Use DXUTGetD3D9Enumeration() to access global instance
//--------------------------------------------------------------------------------------
class CD3D10Enumeration
{
public:
    // These should be called before Enumerate(). 
    //
    // Use these calls and the IsDeviceAcceptable to control the contents of 
    // the enumeration object, which affects the device selection and the device settings dialog.
    void SetResolutionMinMax( UINT nMinWidth, UINT nMinHeight, UINT nMaxWidth, UINT nMaxHeight );  
    void SetRefreshMinMax( UINT nMin, UINT nMax );
    void SetMultisampleQualityMax( UINT nMax );
    CGrowableArray<D3DFORMAT>* GetPossibleDepthStencilFormatList();
    void ResetPossibleDepthStencilFormats();
    void SetEnumerateAllAdapterFormats( bool bEnumerateAllAdapterFormats, bool bEnumerateNow = true );

    // Call Enumerate() to enumerate available D3D10 adapters, devices, modes, etc.
    bool HasEnumerated() { return m_bHasEnumerated; }
    HRESULT Enumerate( LPDXUTCALLBACKISD3D10DEVICEACCEPTABLE IsD3D10DeviceAcceptableFunc,
                       void* pIsD3D10DeviceAcceptableFuncUserContext );

    // These should be called after Enumerate() is called
    CGrowableArray<CD3D10EnumAdapterInfo*>*  GetAdapterInfoList();
    CD3D10EnumAdapterInfo*                   GetAdapterInfo( UINT AdapterOrdinal );
    CD3D10EnumDeviceInfo*                    GetDeviceInfo( UINT AdapterOrdinal, D3D10_DRIVER_TYPE DeviceType );
    CD3D10EnumOutputInfo*                    GetOutputInfo( UINT AdapterOrdinal, UINT Output );
    CD3D10EnumDeviceSettingsCombo*           GetDeviceSettingsCombo( DXUTD3D10DeviceSettings* pDeviceSettings ) { return GetDeviceSettingsCombo( pDeviceSettings->AdapterOrdinal, pDeviceSettings->DriverType, pDeviceSettings->Output, pDeviceSettings->sd.BufferDesc.Format, pDeviceSettings->sd.Windowed ); }
    CD3D10EnumDeviceSettingsCombo*           GetDeviceSettingsCombo( UINT AdapterOrdinal, D3D10_DRIVER_TYPE DeviceType, UINT Output, DXGI_FORMAT BackBufferFormat, BOOL Windowed );

    ~CD3D10Enumeration();

private:
    friend HRESULT WINAPI DXUTCreateD3D10Enumeration();

    // Use DXUTGetD3D10Enumeration() to access global instance
    CD3D10Enumeration();

    bool m_bHasEnumerated;
    LPDXUTCALLBACKISD3D10DEVICEACCEPTABLE m_IsD3D10DeviceAcceptableFunc;
    void* m_pIsD3D10DeviceAcceptableFuncUserContext;

    CGrowableArray<DXGI_FORMAT> m_DepthStencilPossibleList;

    UINT m_nMinWidth;
    UINT m_nMaxWidth;
    UINT m_nMinHeight;
    UINT m_nMaxHeight;
    UINT m_nRefreshMin;
    UINT m_nRefreshMax;
    UINT m_nMultisampleQualityMax;
    bool m_bEnumerateAllAdapterFormats;

    // Array of CD3D9EnumAdapterInfo* with unique AdapterOrdinals
    CGrowableArray<CD3D10EnumAdapterInfo*> m_AdapterInfoList;

    HRESULT EnumerateOutputs( CD3D10EnumAdapterInfo *pAdapterInfo );
    HRESULT EnumerateDevices( CD3D10EnumAdapterInfo *pAdapterInfo );
    HRESULT EnumerateDeviceCombos( IDXGIFactory *pFactory, CD3D10EnumAdapterInfo* pAdapterInfo );
    HRESULT EnumerateDisplayModes( CD3D10EnumOutputInfo *pOutputInfo );
    void BuildMultiSampleQualityList( DXGI_FORMAT fmt, CD3D10EnumDeviceSettingsCombo* pDeviceCombo );
    void ClearAdapterInfoList();
};

CD3D10Enumeration* WINAPI DXUTGetD3D10Enumeration( bool bForceEnumerate = false, bool EnumerateAllAdapterFormats = false );


#define DXGI_MAX_DEVICE_IDENTIFIER_STRING 128

//--------------------------------------------------------------------------------------
// A class describing an adapter which contains a unique adapter ordinal 
// that is installed on the system
//--------------------------------------------------------------------------------------
class CD3D10EnumAdapterInfo
{
    const CD3D10EnumAdapterInfo &operator = ( const CD3D10EnumAdapterInfo &rhs );

public:
    ~CD3D10EnumAdapterInfo();

    UINT AdapterOrdinal;
    DXGI_ADAPTER_DESC AdapterDesc;
    WCHAR szUniqueDescription[DXGI_MAX_DEVICE_IDENTIFIER_STRING];
    IDXGIAdapter *m_pAdapter;

    CGrowableArray<CD3D10EnumOutputInfo*> outputInfoList; // Array of CD3D10EnumOutputInfo*
    CGrowableArray<CD3D10EnumDeviceInfo*> deviceInfoList; // Array of CD3D10EnumDeviceInfo*
    // List of CD3D10EnumDeviceSettingsCombo* with a unique set 
    // of BackBufferFormat, and Windowed
    CGrowableArray<CD3D10EnumDeviceSettingsCombo*> deviceSettingsComboList;
};


class CD3D10EnumOutputInfo
{
    const CD3D10EnumOutputInfo &operator = ( const CD3D10EnumOutputInfo &rhs );

public:
    ~CD3D10EnumOutputInfo();

    UINT AdapterOrdinal;
    UINT Output;
    IDXGIOutput *m_pOutput;
    DXGI_OUTPUT_DESC Desc;

    CGrowableArray<DXGI_MODE_DESC> displayModeList; // Array of supported D3DDISPLAYMODEs
};


//--------------------------------------------------------------------------------------
// A class describing a Direct3D10 device that contains a 
//       unique supported driver type
//--------------------------------------------------------------------------------------
class CD3D10EnumDeviceInfo
{
    const CD3D10EnumDeviceInfo &operator = ( const CD3D10EnumDeviceInfo &rhs );

public:
    ~CD3D10EnumDeviceInfo();

    UINT AdapterOrdinal;
    D3D10_DRIVER_TYPE DeviceType;
};


//--------------------------------------------------------------------------------------
// A struct describing device settings that contains a unique combination of 
// adapter format, back buffer format, and windowed that is compatible with a 
// particular Direct3D device and the app.
//--------------------------------------------------------------------------------------
struct CD3D10EnumDeviceSettingsCombo
{
    UINT AdapterOrdinal;
    D3D10_DRIVER_TYPE DeviceType;
    DXGI_FORMAT BackBufferFormat;
    BOOL Windowed;
    UINT Output;

    CGrowableArray<UINT> multiSampleCountList; // List of valid sampling counts (multisampling)
    CGrowableArray<UINT> multiSampleQualityList; // List of number of quality levels for each multisample count

    CD3D10EnumAdapterInfo* pAdapterInfo;
    CD3D10EnumDeviceInfo* pDeviceInfo;
    CD3D10EnumOutputInfo* pOutputInfo;
};


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -