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