d3denumeration.h
上传用户:sycq158
上传日期:2008-10-22
资源大小:15361k
文件大小:5k
源码类别:

游戏

开发平台:

Visual C++

  1. //-----------------------------------------------------------------------------
  2. // File: D3DEnumeration.h
  3. //
  4. // Desc: Enumerates D3D adapters, devices, modes, etc.
  5. //
  6. // Copyright (c) Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #ifndef D3DENUM_H
  9. #define D3DENUM_H
  10. //-----------------------------------------------------------------------------
  11. // Name: enum VertexProcessingType
  12. // Desc: Enumeration of all possible D3D vertex processing types.
  13. //-----------------------------------------------------------------------------
  14. enum VertexProcessingType
  15. {
  16.     SOFTWARE_VP,
  17.     MIXED_VP,
  18.     HARDWARE_VP,
  19.     PURE_HARDWARE_VP
  20. };
  21. //-----------------------------------------------------------------------------
  22. // Name: struct D3DAdapterInfo
  23. // Desc: Info about a display adapter.
  24. //-----------------------------------------------------------------------------
  25. struct D3DAdapterInfo
  26. {
  27.     int AdapterOrdinal;
  28.     D3DADAPTER_IDENTIFIER9 AdapterIdentifier;
  29.     CArrayList* pDisplayModeList; // List of D3DDISPLAYMODEs
  30.     CArrayList* pDeviceInfoList; // List of D3DDeviceInfo pointers
  31.     ~D3DAdapterInfo( void );
  32. };
  33. //-----------------------------------------------------------------------------
  34. // Name: struct D3DDeviceInfo
  35. // Desc: Info about a D3D device, including a list of D3DDeviceCombos (see below) 
  36. //       that work with the device.
  37. //-----------------------------------------------------------------------------
  38. struct D3DDeviceInfo
  39. {
  40.     int AdapterOrdinal;
  41.     D3DDEVTYPE DevType;
  42.     D3DCAPS9 Caps;
  43.     CArrayList* pDeviceComboList; // List of D3DDeviceCombo pointers
  44.     ~D3DDeviceInfo( void );
  45. };
  46. //-----------------------------------------------------------------------------
  47. // Name: struct D3DDSMSConflict
  48. // Desc: A depth/stencil buffer format that is incompatible with a
  49. //       multisample type.
  50. //-----------------------------------------------------------------------------
  51. struct D3DDSMSConflict
  52. {
  53.     D3DFORMAT DSFormat;
  54.     D3DMULTISAMPLE_TYPE MSType;
  55. };
  56. //-----------------------------------------------------------------------------
  57. // Name: struct D3DDeviceCombo
  58. // Desc: A combination of adapter format, back buffer format, and windowed/fullscreen 
  59. //       that is compatible with a particular D3D device (and the app).
  60. //-----------------------------------------------------------------------------
  61. struct D3DDeviceCombo
  62. {
  63.     int AdapterOrdinal;
  64.     D3DDEVTYPE DevType;
  65.     D3DFORMAT AdapterFormat;
  66.     D3DFORMAT BackBufferFormat;
  67.     bool IsWindowed;
  68.     CArrayList* pDepthStencilFormatList; // List of D3DFORMATs
  69.     CArrayList* pMultiSampleTypeList; // List of D3DMULTISAMPLE_TYPEs
  70.     CArrayList* pMultiSampleQualityList; // List of DWORDs (number of quality 
  71.                                          // levels for each multisample type)
  72.     CArrayList* pDSMSConflictList; // List of D3DDSMSConflicts
  73.     CArrayList* pVertexProcessingTypeList; // List of VertexProcessingTypes
  74.     CArrayList* pPresentIntervalList; // List of D3DPRESENT_INTERVALs
  75.     ~D3DDeviceCombo( void );
  76. };
  77. typedef bool(* CONFIRMDEVICECALLBACK)( D3DCAPS9* pCaps, VertexProcessingType vertexProcessingType, 
  78.    D3DFORMAT adapterFormat, D3DFORMAT backBufferFormat );
  79. //-----------------------------------------------------------------------------
  80. // Name: class CD3DEnumeration
  81. // Desc: Enumerates available D3D adapters, devices, modes, etc.
  82. //-----------------------------------------------------------------------------
  83. class CD3DEnumeration
  84. {
  85. private:
  86.     IDirect3D9* m_pD3D;
  87. private:
  88.     HRESULT EnumerateDevices( D3DAdapterInfo* pAdapterInfo, CArrayList* pAdapterFormatList );
  89.     HRESULT EnumerateDeviceCombos( D3DDeviceInfo* pDeviceInfo, CArrayList* pAdapterFormatList );
  90.     void BuildDepthStencilFormatList( D3DDeviceCombo* pDeviceCombo );
  91.     void BuildMultiSampleTypeList( D3DDeviceCombo* pDeviceCombo );
  92.     void BuildDSMSConflictList( D3DDeviceCombo* pDeviceCombo );
  93.     void BuildVertexProcessingTypeList( D3DDeviceInfo* pDeviceInfo, D3DDeviceCombo* pDeviceCombo );
  94.     void BuildPresentIntervalList( D3DDeviceInfo* pDeviceInfo, D3DDeviceCombo* pDeviceCombo );
  95. public:
  96.     CArrayList* m_pAdapterInfoList;
  97.     // The following variables can be used to limit what modes, formats, 
  98.     // etc. are enumerated.  Set them to the values you want before calling
  99.     // Enumerate().
  100.     CONFIRMDEVICECALLBACK ConfirmDeviceCallback;
  101.     UINT AppMinFullscreenWidth;
  102.     UINT AppMinFullscreenHeight;
  103.     UINT AppMinColorChannelBits; // min color bits per channel in adapter format
  104.     UINT AppMinAlphaChannelBits; // min alpha bits per pixel in back buffer format
  105.     UINT AppMinDepthBits;
  106.     UINT AppMinStencilBits;
  107.     bool AppUsesDepthBuffer;
  108.     bool AppUsesMixedVP; // whether app can take advantage of mixed vp mode
  109.     bool AppRequiresWindowed;
  110.     bool AppRequiresFullscreen;
  111.     CArrayList* m_pAllowedAdapterFormatList; // list of D3DFORMATs
  112.     CD3DEnumeration();
  113.     ~CD3DEnumeration();
  114.     void SetD3D(IDirect3D9* pD3D) { m_pD3D = pD3D; }
  115.     IDirect3D9 *GetD3D() { if( m_pD3D ) m_pD3D->AddRef(); return m_pD3D; }
  116.     HRESULT Enumerate();
  117. };
  118. #endif