home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the 3D Game Programming Gurus / gurus.iso / DirectX / dx9sdkcp.exe / SDK (C++) / Bin / DXUtils / Visual Studio 6.0 Wizards / Source Code / Template / d3denumeration.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-11-12  |  5.0 KB  |  135 lines

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