1 | //--------------------------------------------------------------------------------------
|
---|
2 | // File: DXUTSettingsDlg.cpp
|
---|
3 | //
|
---|
4 | // Dialog for selection of device settings
|
---|
5 | //
|
---|
6 | // Copyright (c) Microsoft Corporation. All rights reserved
|
---|
7 | //--------------------------------------------------------------------------------------
|
---|
8 | #include "dxstdafx.h"
|
---|
9 |
|
---|
10 |
|
---|
11 | //--------------------------------------------------------------------------------------
|
---|
12 | // Internal functions forward declarations
|
---|
13 | //--------------------------------------------------------------------------------------
|
---|
14 | WCHAR* DXUTPresentIntervalToString( UINT pi );
|
---|
15 | WCHAR* DXUTMultisampleTypeToString(D3DMULTISAMPLE_TYPE MultiSampleType);
|
---|
16 | WCHAR* DXUTD3DDeviceTypeToString(D3DDEVTYPE devType);
|
---|
17 | WCHAR* DXUTVertexProcessingTypeToString(DWORD vpt);
|
---|
18 |
|
---|
19 |
|
---|
20 | //--------------------------------------------------------------------------------------
|
---|
21 | // Global state
|
---|
22 | //--------------------------------------------------------------------------------------
|
---|
23 | CD3DSettingsDlg* g_pD3DSettings = NULL;
|
---|
24 | DXUTDeviceSettings g_DeviceSettings;
|
---|
25 |
|
---|
26 | CD3DSettingsDlg* DXUTGetSettingsDialog()
|
---|
27 | {
|
---|
28 | // Using an accessor function gives control of the construction order
|
---|
29 | static CD3DSettingsDlg dlg;
|
---|
30 | return &dlg;
|
---|
31 | }
|
---|
32 |
|
---|
33 |
|
---|
34 | //--------------------------------------------------------------------------------------
|
---|
35 | CD3DSettingsDlg::CD3DSettingsDlg()
|
---|
36 | {
|
---|
37 | g_pD3DSettings = this;
|
---|
38 |
|
---|
39 | m_dwWindowWidth = 640;
|
---|
40 | m_dwWindowHeight = 480;
|
---|
41 |
|
---|
42 | CreateControls();
|
---|
43 | }
|
---|
44 |
|
---|
45 |
|
---|
46 | //--------------------------------------------------------------------------------------
|
---|
47 | CD3DSettingsDlg::~CD3DSettingsDlg()
|
---|
48 | {
|
---|
49 | OnDestroyDevice();
|
---|
50 | }
|
---|
51 |
|
---|
52 |
|
---|
53 | //--------------------------------------------------------------------------------------
|
---|
54 | void CD3DSettingsDlg::CreateControls()
|
---|
55 | {
|
---|
56 | m_Dialog.EnableKeyboardInput( true );
|
---|
57 | m_Dialog.SetFont( 0, L"Arial", 15, FW_NORMAL );
|
---|
58 | m_Dialog.SetFont( 1, L"Arial", 28, FW_BOLD );
|
---|
59 |
|
---|
60 | // Right-justify static controls
|
---|
61 | CDXUTElement* pElement = m_Dialog.GetDefaultElement( DXUT_CONTROL_STATIC, 0 );
|
---|
62 | if( pElement )
|
---|
63 | {
|
---|
64 | pElement->dwTextFormat = DT_VCENTER | DT_RIGHT;
|
---|
65 |
|
---|
66 | // Title
|
---|
67 | CDXUTStatic* pStatic = NULL;
|
---|
68 | m_Dialog.AddStatic( DXUTSETTINGSDLG_STATIC, L"Direct3D Settings", 10, 5, 400, 50, false, &pStatic );
|
---|
69 | pElement = pStatic->GetElement( 0 );
|
---|
70 | pElement->iFont = 1;
|
---|
71 | pElement->dwTextFormat = DT_TOP | DT_LEFT;
|
---|
72 | }
|
---|
73 |
|
---|
74 | // DXUTSETTINGSDLG_ADAPTER
|
---|
75 | m_Dialog.AddStatic( DXUTSETTINGSDLG_STATIC, L"Display Adapter", 10, 50, 180, 23 );
|
---|
76 | m_Dialog.AddComboBox( DXUTSETTINGSDLG_ADAPTER, 200, 50, 300, 23 );
|
---|
77 |
|
---|
78 | // DXUTSETTINGSDLG_DEVICE_TYPE
|
---|
79 | m_Dialog.AddStatic( DXUTSETTINGSDLG_STATIC, L"Render Device", 10, 75, 180, 23 );
|
---|
80 | m_Dialog.AddComboBox( DXUTSETTINGSDLG_DEVICE_TYPE, 200, 75, 300, 23 );
|
---|
81 |
|
---|
82 | // DXUTSETTINGSDLG_WINDOWED, DXUTSETTINGSDLG_FULLSCREEN
|
---|
83 | m_Dialog.AddRadioButton( DXUTSETTINGSDLG_WINDOWED, DXUTSETTINGSDLG_WINDOWED_GROUP, L"Windowed", 240, 105, 300, 16 );
|
---|
84 | m_Dialog.AddCheckBox( DXUTSETTINGSDLG_DEVICECLIP, L"Clip to device when window spans across multiple monitors", 250, 126, 400, 16 );
|
---|
85 | m_Dialog.AddRadioButton( DXUTSETTINGSDLG_FULLSCREEN, DXUTSETTINGSDLG_WINDOWED_GROUP, L"Full Screen", 240, 147, 300, 16 );
|
---|
86 |
|
---|
87 | // DXUTSETTINGSDLG_ADAPTER_FORMAT
|
---|
88 | m_Dialog.AddStatic( DXUTSETTINGSDLG_ADAPTER_FORMAT_LABEL, L"Adapter Format", 10, 180, 180, 23 );
|
---|
89 | m_Dialog.AddComboBox( DXUTSETTINGSDLG_ADAPTER_FORMAT, 200, 180, 300, 23 );
|
---|
90 |
|
---|
91 | // DXUTSETTINGSDLG_RESOLUTION
|
---|
92 | m_Dialog.AddStatic( DXUTSETTINGSDLG_RESOLUTION_LABEL, L"Resolution", 10, 205, 180, 23 );
|
---|
93 | m_Dialog.AddComboBox( DXUTSETTINGSDLG_RESOLUTION, 200, 205, 300, 23 );
|
---|
94 | m_Dialog.GetComboBox( DXUTSETTINGSDLG_RESOLUTION )->SetDropHeight( 106 );
|
---|
95 |
|
---|
96 | // DXUTSETTINGSDLG_REFRESH_RATE
|
---|
97 | m_Dialog.AddStatic( DXUTSETTINGSDLG_REFRESH_RATE_LABEL, L"Refresh Rate", 10, 230, 180, 23 );
|
---|
98 | m_Dialog.AddComboBox( DXUTSETTINGSDLG_REFRESH_RATE, 200, 230, 300, 23 );
|
---|
99 |
|
---|
100 | // DXUTSETTINGSDLG_BACK_BUFFER_FORMAT
|
---|
101 | m_Dialog.AddStatic( DXUTSETTINGSDLG_STATIC, L"Back Buffer Format", 10, 265, 180, 23 );
|
---|
102 | m_Dialog.AddComboBox( DXUTSETTINGSDLG_BACK_BUFFER_FORMAT, 200, 265, 300, 23 );
|
---|
103 |
|
---|
104 | // DXUTSETTINGSDLG_DEPTH_STENCIL
|
---|
105 | m_Dialog.AddStatic( DXUTSETTINGSDLG_STATIC, L"Depth/Stencil Format", 10, 290, 180, 23 );
|
---|
106 | m_Dialog.AddComboBox( DXUTSETTINGSDLG_DEPTH_STENCIL, 200, 290, 300, 23 );
|
---|
107 |
|
---|
108 | // DXUTSETTINGSDLG_MULTISAMPLE_TYPE
|
---|
109 | m_Dialog.AddStatic( DXUTSETTINGSDLG_STATIC, L"Multisample Type", 10, 315, 180, 23 );
|
---|
110 | m_Dialog.AddComboBox( DXUTSETTINGSDLG_MULTISAMPLE_TYPE, 200, 315, 300, 23 );
|
---|
111 |
|
---|
112 | // DXUTSETTINGSDLG_MULTISAMPLE_QUALITY
|
---|
113 | m_Dialog.AddStatic( DXUTSETTINGSDLG_STATIC, L"Multisample Quality", 10, 340, 180, 23 );
|
---|
114 | m_Dialog.AddComboBox( DXUTSETTINGSDLG_MULTISAMPLE_QUALITY, 200, 340, 300, 23 );
|
---|
115 |
|
---|
116 | // DXUTSETTINGSDLG_VERTEX_PROCESSING
|
---|
117 | m_Dialog.AddStatic( DXUTSETTINGSDLG_STATIC, L"Vertex Processing", 10, 365, 180, 23 );
|
---|
118 | m_Dialog.AddComboBox( DXUTSETTINGSDLG_VERTEX_PROCESSING, 200, 365, 300, 23 );
|
---|
119 |
|
---|
120 | // DXUTSETTINGSDLG_PRESENT_INTERVAL
|
---|
121 | m_Dialog.AddStatic( DXUTSETTINGSDLG_STATIC, L"Present Interval", 10, 390, 180, 23 );
|
---|
122 | m_Dialog.AddComboBox( DXUTSETTINGSDLG_PRESENT_INTERVAL, 200, 390, 300, 23 );
|
---|
123 |
|
---|
124 | // DXUTSETTINGSDLG_OK, DXUTSETTINGSDLG_CANCEL
|
---|
125 | m_Dialog.AddButton( DXUTSETTINGSDLG_OK, L"OK", 230, 435, 73, 31 );
|
---|
126 | m_Dialog.AddButton( DXUTSETTINGSDLG_CANCEL, L"Cancel", 315, 435, 73, 31, 0, true );
|
---|
127 | }
|
---|
128 |
|
---|
129 |
|
---|
130 | //--------------------------------------------------------------------------------------
|
---|
131 | HRESULT CD3DSettingsDlg::OnCreateDevice( IDirect3DDevice9* pd3dDevice )
|
---|
132 | {
|
---|
133 | if( pd3dDevice == NULL )
|
---|
134 | return DXUT_ERR_MSGBOX( L"CD3DSettingsDlg::OnCreatedDevice", E_INVALIDARG );
|
---|
135 |
|
---|
136 | // Create the fonts/textures
|
---|
137 | m_Dialog.SetCallback( StaticOnEvent );
|
---|
138 |
|
---|
139 | return S_OK;
|
---|
140 | }
|
---|
141 |
|
---|
142 |
|
---|
143 | //--------------------------------------------------------------------------------------
|
---|
144 | // Changes the UI defaults to the current device settings
|
---|
145 | //--------------------------------------------------------------------------------------
|
---|
146 | HRESULT CD3DSettingsDlg::Refresh()
|
---|
147 | {
|
---|
148 | HRESULT hr = S_OK;
|
---|
149 |
|
---|
150 | CD3DEnumeration* pD3DEnum = DXUTGetEnumeration();
|
---|
151 | g_DeviceSettings = DXUTGetDeviceSettings();
|
---|
152 |
|
---|
153 | RECT rcClient = DXUTGetWindowClientRect();
|
---|
154 | m_dwWindowWidth = rcClient.right - rcClient.left;
|
---|
155 | m_dwWindowHeight = rcClient.bottom - rcClient.top;
|
---|
156 |
|
---|
157 | // Fill the UI with the current settings
|
---|
158 | AddDeviceType( g_DeviceSettings.DeviceType );
|
---|
159 | SetWindowed( FALSE != g_DeviceSettings.pp.Windowed );
|
---|
160 | SetDeviceClip( 0 != (g_DeviceSettings.pp.Flags & D3DPRESENTFLAG_DEVICECLIP) );
|
---|
161 | AddAdapterFormat( g_DeviceSettings.AdapterFormat );
|
---|
162 | AddResolution( g_DeviceSettings.pp.BackBufferWidth, g_DeviceSettings.pp.BackBufferHeight );
|
---|
163 | AddRefreshRate( g_DeviceSettings.pp.FullScreen_RefreshRateInHz );
|
---|
164 | AddBackBufferFormat( g_DeviceSettings.pp.BackBufferFormat );
|
---|
165 | AddDepthStencilBufferFormat( g_DeviceSettings.pp.AutoDepthStencilFormat );
|
---|
166 | AddMultisampleType( g_DeviceSettings.pp.MultiSampleType );
|
---|
167 | AddMultisampleQuality( g_DeviceSettings.pp.MultiSampleQuality );
|
---|
168 |
|
---|
169 | if( g_DeviceSettings.BehaviorFlags & D3DCREATE_PUREDEVICE )
|
---|
170 | AddVertexProcessingType( D3DCREATE_PUREDEVICE );
|
---|
171 | else if( g_DeviceSettings.BehaviorFlags & D3DCREATE_HARDWARE_VERTEXPROCESSING )
|
---|
172 | AddVertexProcessingType( D3DCREATE_HARDWARE_VERTEXPROCESSING );
|
---|
173 | else if( g_DeviceSettings.BehaviorFlags & D3DCREATE_SOFTWARE_VERTEXPROCESSING )
|
---|
174 | AddVertexProcessingType( D3DCREATE_SOFTWARE_VERTEXPROCESSING );
|
---|
175 | else if( g_DeviceSettings.BehaviorFlags & D3DCREATE_MIXED_VERTEXPROCESSING )
|
---|
176 | AddVertexProcessingType( D3DCREATE_MIXED_VERTEXPROCESSING );
|
---|
177 |
|
---|
178 | AddPresentInterval( g_DeviceSettings.pp.PresentationInterval );
|
---|
179 |
|
---|
180 |
|
---|
181 | CD3DEnumDeviceSettingsCombo* pBestDeviceSettingsCombo = pD3DEnum->GetDeviceSettingsCombo( g_DeviceSettings.AdapterOrdinal, g_DeviceSettings.DeviceType, g_DeviceSettings.AdapterFormat, g_DeviceSettings.pp.BackBufferFormat, (g_DeviceSettings.pp.Windowed != 0) );
|
---|
182 | if( NULL == pBestDeviceSettingsCombo )
|
---|
183 | return DXUT_ERR_MSGBOX( L"GetDeviceSettingsCombo", E_INVALIDARG );
|
---|
184 |
|
---|
185 | // Get the adapters list from CD3DEnumeration object
|
---|
186 | CGrowableArray<CD3DEnumAdapterInfo*>* pAdapterInfoList = pD3DEnum->GetAdapterInfoList();
|
---|
187 |
|
---|
188 | if( pAdapterInfoList->GetSize() == 0 )
|
---|
189 | return DXUT_ERR_MSGBOX( L"CD3DSettingsDlg::OnCreatedDevice", DXUTERR_NOCOMPATIBLEDEVICES );
|
---|
190 |
|
---|
191 | CDXUTComboBox* pAdapterCombo = m_Dialog.GetComboBox( DXUTSETTINGSDLG_ADAPTER );
|
---|
192 | pAdapterCombo->RemoveAllItems();
|
---|
193 |
|
---|
194 | // Add adapters
|
---|
195 | for( int iAdapter=0; iAdapter<pAdapterInfoList->GetSize(); iAdapter++ )
|
---|
196 | {
|
---|
197 | CD3DEnumAdapterInfo* pAdapterInfo = pAdapterInfoList->GetAt(iAdapter);
|
---|
198 | AddAdapter( pAdapterInfo->szUniqueDescription, pAdapterInfo->AdapterOrdinal );
|
---|
199 | }
|
---|
200 |
|
---|
201 | pAdapterCombo->SetSelectedByData( ULongToPtr( g_DeviceSettings.AdapterOrdinal ) );
|
---|
202 |
|
---|
203 | hr = OnAdapterChanged();
|
---|
204 | if( FAILED(hr) )
|
---|
205 | return hr;
|
---|
206 |
|
---|
207 | //m_Dialog.Refresh();
|
---|
208 | CDXUTDialog::SetRefreshTime( (float) DXUTGetTime() );
|
---|
209 |
|
---|
210 | return S_OK;
|
---|
211 | }
|
---|
212 |
|
---|
213 |
|
---|
214 | //--------------------------------------------------------------------------------------
|
---|
215 | HRESULT CD3DSettingsDlg::OnResetDevice()
|
---|
216 | {
|
---|
217 | const D3DSURFACE_DESC* pDesc = DXUTGetBackBufferSurfaceDesc();
|
---|
218 | m_Dialog.SetLocation( 0, 0 );
|
---|
219 | m_Dialog.SetSize( pDesc->Width, pDesc->Height );
|
---|
220 | m_Dialog.SetBackgroundColors( D3DCOLOR_ARGB(255, 98, 138, 206),
|
---|
221 | D3DCOLOR_ARGB(255, 54, 105, 192),
|
---|
222 | D3DCOLOR_ARGB(255, 54, 105, 192),
|
---|
223 | D3DCOLOR_ARGB(255, 10, 73, 179) );
|
---|
224 |
|
---|
225 | return S_OK;
|
---|
226 | }
|
---|
227 |
|
---|
228 |
|
---|
229 | //--------------------------------------------------------------------------------------
|
---|
230 | HRESULT CD3DSettingsDlg::OnRender( float fElapsedTime )
|
---|
231 | {
|
---|
232 | m_Dialog.OnRender( fElapsedTime );
|
---|
233 | return S_OK;
|
---|
234 | }
|
---|
235 |
|
---|
236 |
|
---|
237 | //--------------------------------------------------------------------------------------
|
---|
238 | LRESULT CD3DSettingsDlg::HandleMessages( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
|
---|
239 | {
|
---|
240 | m_Dialog.MsgProc( hWnd, uMsg, wParam, lParam );
|
---|
241 | return 0;
|
---|
242 | }
|
---|
243 |
|
---|
244 |
|
---|
245 | //--------------------------------------------------------------------------------------
|
---|
246 | HRESULT CD3DSettingsDlg::OnLostDevice()
|
---|
247 | {
|
---|
248 | return S_OK;
|
---|
249 | }
|
---|
250 |
|
---|
251 |
|
---|
252 | //--------------------------------------------------------------------------------------
|
---|
253 | HRESULT CD3DSettingsDlg::OnDestroyDevice()
|
---|
254 | {
|
---|
255 | m_Dialog.ClearFocus();
|
---|
256 | return S_OK;
|
---|
257 | }
|
---|
258 |
|
---|
259 |
|
---|
260 | //--------------------------------------------------------------------------------------
|
---|
261 | void WINAPI CD3DSettingsDlg::StaticOnEvent( UINT nEvent, int nControlID,
|
---|
262 | CDXUTControl* pControl )
|
---|
263 | {
|
---|
264 | if( g_pD3DSettings )
|
---|
265 | g_pD3DSettings->OnEvent( nEvent, nControlID, pControl );
|
---|
266 | }
|
---|
267 |
|
---|
268 |
|
---|
269 | //--------------------------------------------------------------------------------------
|
---|
270 | void CD3DSettingsDlg::OnEvent( UINT nEvent, int nControlID,
|
---|
271 | CDXUTControl* pControl )
|
---|
272 | {
|
---|
273 | switch( nControlID )
|
---|
274 | {
|
---|
275 | case DXUTSETTINGSDLG_ADAPTER: OnAdapterChanged(); break;
|
---|
276 | case DXUTSETTINGSDLG_DEVICE_TYPE: OnDeviceTypeChanged(); break;
|
---|
277 | case DXUTSETTINGSDLG_WINDOWED: OnWindowedFullScreenChanged(); break;
|
---|
278 | case DXUTSETTINGSDLG_FULLSCREEN: OnWindowedFullScreenChanged(); break;
|
---|
279 | case DXUTSETTINGSDLG_ADAPTER_FORMAT: OnAdapterFormatChanged(); break;
|
---|
280 | case DXUTSETTINGSDLG_RESOLUTION: OnResolutionChanged(); break;
|
---|
281 | case DXUTSETTINGSDLG_REFRESH_RATE: OnRefreshRateChanged(); break;
|
---|
282 | case DXUTSETTINGSDLG_BACK_BUFFER_FORMAT: OnBackBufferFormatChanged(); break;
|
---|
283 | case DXUTSETTINGSDLG_DEPTH_STENCIL: OnDepthStencilBufferFormatChanged(); break;
|
---|
284 | case DXUTSETTINGSDLG_MULTISAMPLE_TYPE: OnMultisampleTypeChanged(); break;
|
---|
285 | case DXUTSETTINGSDLG_MULTISAMPLE_QUALITY: OnMultisampleQualityChanged(); break;
|
---|
286 | case DXUTSETTINGSDLG_VERTEX_PROCESSING: OnVertexProcessingChanged(); break;
|
---|
287 | case DXUTSETTINGSDLG_PRESENT_INTERVAL: OnPresentIntervalChanged(); break;
|
---|
288 | case DXUTSETTINGSDLG_DEVICECLIP: OnDeviceClipChanged(); break;
|
---|
289 |
|
---|
290 | case DXUTSETTINGSDLG_OK:
|
---|
291 | {
|
---|
292 | if( g_DeviceSettings.pp.Windowed )
|
---|
293 | {
|
---|
294 | g_DeviceSettings.pp.FullScreen_RefreshRateInHz = 0;
|
---|
295 | g_DeviceSettings.pp.BackBufferWidth = m_dwWindowWidth;
|
---|
296 | g_DeviceSettings.pp.BackBufferHeight = m_dwWindowHeight;
|
---|
297 | }
|
---|
298 |
|
---|
299 | if( g_DeviceSettings.pp.MultiSampleType != D3DMULTISAMPLE_NONE )
|
---|
300 | {
|
---|
301 | g_DeviceSettings.pp.Flags &= ~D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
|
---|
302 | }
|
---|
303 |
|
---|
304 | DXUTCreateDeviceFromSettings( &g_DeviceSettings );
|
---|
305 |
|
---|
306 | DXUTSetShowSettingsDialog( false );
|
---|
307 | break;
|
---|
308 | }
|
---|
309 |
|
---|
310 | case DXUTSETTINGSDLG_CANCEL:
|
---|
311 | {
|
---|
312 | DXUTSetShowSettingsDialog( false );
|
---|
313 | break;
|
---|
314 | }
|
---|
315 |
|
---|
316 | }
|
---|
317 | }
|
---|
318 |
|
---|
319 |
|
---|
320 | //-------------------------------------------------------------------------------------
|
---|
321 | HRESULT CD3DSettingsDlg::SetDeviceSettingsFromUI()
|
---|
322 | {
|
---|
323 | CDXUTComboBox* pComboBox;
|
---|
324 | CDXUTRadioButton* pRadioButton;
|
---|
325 |
|
---|
326 | // DXUTSETTINGSDLG_DEVICE_TYPE
|
---|
327 | pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_DEVICE_TYPE );
|
---|
328 | g_DeviceSettings.DeviceType = (D3DDEVTYPE) PtrToUlong( pComboBox->GetSelectedData() );
|
---|
329 |
|
---|
330 | // DXUTSETTINGSDLG_WINDOWED
|
---|
331 | pRadioButton = m_Dialog.GetRadioButton( DXUTSETTINGSDLG_WINDOWED );
|
---|
332 | g_DeviceSettings.pp.Windowed = pRadioButton->GetChecked();
|
---|
333 |
|
---|
334 | // DXUTSETTINGSDLG_ADAPTER_FORMAT
|
---|
335 | pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_ADAPTER_FORMAT );
|
---|
336 | g_DeviceSettings.AdapterFormat = (D3DFORMAT) PtrToUlong( pComboBox->GetSelectedData() );
|
---|
337 |
|
---|
338 |
|
---|
339 | if( g_DeviceSettings.pp.Windowed )
|
---|
340 | {
|
---|
341 | g_DeviceSettings.pp.BackBufferFormat = D3DFMT_UNKNOWN;
|
---|
342 | g_DeviceSettings.pp.FullScreen_RefreshRateInHz = 0;
|
---|
343 | }
|
---|
344 | else
|
---|
345 | {
|
---|
346 | // DXUTSETTINGSDLG_BACK_BUFFER_FORMAT
|
---|
347 | pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_BACK_BUFFER_FORMAT );
|
---|
348 | g_DeviceSettings.pp.BackBufferFormat = (D3DFORMAT) PtrToUlong( pComboBox->GetSelectedData() );
|
---|
349 |
|
---|
350 | // DXUTSETTINGSDLG_RESOLUTION
|
---|
351 | pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_RESOLUTION );
|
---|
352 | DWORD dwResolution = PtrToUlong( pComboBox->GetSelectedData() );
|
---|
353 | g_DeviceSettings.pp.BackBufferWidth = HIWORD( dwResolution );
|
---|
354 | g_DeviceSettings.pp.BackBufferHeight = LOWORD( dwResolution );
|
---|
355 |
|
---|
356 | // DXUTSETTINGSDLG_REFRESH_RATE
|
---|
357 | pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_REFRESH_RATE );
|
---|
358 | g_DeviceSettings.pp.FullScreen_RefreshRateInHz = PtrToUlong( pComboBox->GetSelectedData() );
|
---|
359 | }
|
---|
360 |
|
---|
361 | // DXUTSETTINGSDLG_DEPTH_STENCIL
|
---|
362 | pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_DEPTH_STENCIL );
|
---|
363 | g_DeviceSettings.pp.AutoDepthStencilFormat = (D3DFORMAT) PtrToUlong( pComboBox->GetSelectedData() );
|
---|
364 |
|
---|
365 | return S_OK;
|
---|
366 | }
|
---|
367 |
|
---|
368 |
|
---|
369 | //-------------------------------------------------------------------------------------
|
---|
370 | CD3DEnumAdapterInfo* CD3DSettingsDlg::GetCurrentAdapterInfo()
|
---|
371 | {
|
---|
372 | CD3DEnumeration* pD3DEnum = DXUTGetEnumeration();
|
---|
373 | return pD3DEnum->GetAdapterInfo( g_DeviceSettings.AdapterOrdinal );
|
---|
374 | }
|
---|
375 |
|
---|
376 |
|
---|
377 | //-------------------------------------------------------------------------------------
|
---|
378 | CD3DEnumDeviceInfo* CD3DSettingsDlg::GetCurrentDeviceInfo()
|
---|
379 | {
|
---|
380 | CD3DEnumeration* pD3DEnum = DXUTGetEnumeration();
|
---|
381 | return pD3DEnum->GetDeviceInfo( g_DeviceSettings.AdapterOrdinal,
|
---|
382 | g_DeviceSettings.DeviceType );
|
---|
383 | }
|
---|
384 |
|
---|
385 |
|
---|
386 | //-------------------------------------------------------------------------------------
|
---|
387 | CD3DEnumDeviceSettingsCombo* CD3DSettingsDlg::GetCurrentDeviceSettingsCombo()
|
---|
388 | {
|
---|
389 | CD3DEnumeration* pD3DEnum = DXUTGetEnumeration();
|
---|
390 | return pD3DEnum->GetDeviceSettingsCombo( g_DeviceSettings.AdapterOrdinal,
|
---|
391 | g_DeviceSettings.DeviceType,
|
---|
392 | g_DeviceSettings.AdapterFormat,
|
---|
393 | g_DeviceSettings.pp.BackBufferFormat,
|
---|
394 | (g_DeviceSettings.pp.Windowed == TRUE) );
|
---|
395 | }
|
---|
396 |
|
---|
397 |
|
---|
398 | //-------------------------------------------------------------------------------------
|
---|
399 | HRESULT CD3DSettingsDlg::OnAdapterChanged()
|
---|
400 | {
|
---|
401 | HRESULT hr = S_OK;
|
---|
402 |
|
---|
403 | // Store the adapter index
|
---|
404 | g_DeviceSettings.AdapterOrdinal = GetSelectedAdapter();
|
---|
405 |
|
---|
406 | // DXUTSETTINGSDLG_DEVICE_TYPE
|
---|
407 | CDXUTComboBox* pDeviceTypeComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_DEVICE_TYPE );
|
---|
408 | pDeviceTypeComboBox->RemoveAllItems();
|
---|
409 |
|
---|
410 | CD3DEnumAdapterInfo* pAdapterInfo = GetCurrentAdapterInfo();
|
---|
411 | if( pAdapterInfo == NULL )
|
---|
412 | return E_FAIL;
|
---|
413 |
|
---|
414 | for( int iDeviceInfo=0; iDeviceInfo < pAdapterInfo->deviceInfoList.GetSize(); iDeviceInfo++ )
|
---|
415 | {
|
---|
416 | CD3DEnumDeviceInfo* pDeviceInfo = pAdapterInfo->deviceInfoList.GetAt(iDeviceInfo);
|
---|
417 | AddDeviceType( pDeviceInfo->DeviceType );
|
---|
418 | }
|
---|
419 |
|
---|
420 | pDeviceTypeComboBox->SetSelectedByData( ULongToPtr(g_DeviceSettings.DeviceType) );
|
---|
421 |
|
---|
422 | hr = OnDeviceTypeChanged();
|
---|
423 | if( FAILED(hr) )
|
---|
424 | return hr;
|
---|
425 |
|
---|
426 | return S_OK;
|
---|
427 | }
|
---|
428 |
|
---|
429 |
|
---|
430 |
|
---|
431 | //-------------------------------------------------------------------------------------
|
---|
432 | HRESULT CD3DSettingsDlg::OnDeviceTypeChanged()
|
---|
433 | {
|
---|
434 | HRESULT hr = S_OK;
|
---|
435 |
|
---|
436 | g_DeviceSettings.DeviceType = GetSelectedDeviceType();
|
---|
437 |
|
---|
438 | // Update windowed/full screen radio buttons
|
---|
439 | bool bHasWindowedDeviceCombo = false;
|
---|
440 | bool bHasFullScreenDeviceCombo = false;
|
---|
441 |
|
---|
442 | CD3DEnumDeviceInfo* pDeviceInfo = GetCurrentDeviceInfo();
|
---|
443 | if( pDeviceInfo == NULL )
|
---|
444 | return E_FAIL;
|
---|
445 |
|
---|
446 | for( int idc = 0; idc < pDeviceInfo->deviceSettingsComboList.GetSize(); idc++ )
|
---|
447 | {
|
---|
448 | CD3DEnumDeviceSettingsCombo* pDeviceSettingsCombo = pDeviceInfo->deviceSettingsComboList.GetAt( idc );
|
---|
449 |
|
---|
450 | if( pDeviceSettingsCombo->Windowed )
|
---|
451 | bHasWindowedDeviceCombo = true;
|
---|
452 | else
|
---|
453 | bHasFullScreenDeviceCombo = true;
|
---|
454 | }
|
---|
455 |
|
---|
456 | // DXUTSETTINGSDLG_WINDOWED, DXUTSETTINGSDLG_FULLSCREEN
|
---|
457 | m_Dialog.SetControlEnabled( DXUTSETTINGSDLG_WINDOWED, bHasWindowedDeviceCombo );
|
---|
458 | m_Dialog.SetControlEnabled( DXUTSETTINGSDLG_FULLSCREEN, bHasFullScreenDeviceCombo );
|
---|
459 |
|
---|
460 | SetWindowed( g_DeviceSettings.pp.Windowed && bHasWindowedDeviceCombo );
|
---|
461 |
|
---|
462 | hr = OnWindowedFullScreenChanged();
|
---|
463 | if( FAILED(hr) )
|
---|
464 | return hr;
|
---|
465 |
|
---|
466 | return S_OK;
|
---|
467 | }
|
---|
468 |
|
---|
469 |
|
---|
470 |
|
---|
471 | //-------------------------------------------------------------------------------------
|
---|
472 | HRESULT CD3DSettingsDlg::OnWindowedFullScreenChanged()
|
---|
473 | {
|
---|
474 | HRESULT hr = S_OK;
|
---|
475 |
|
---|
476 | bool bWindowed = IsWindowed();
|
---|
477 | g_DeviceSettings.pp.Windowed = bWindowed;
|
---|
478 |
|
---|
479 | m_Dialog.SetControlEnabled( DXUTSETTINGSDLG_ADAPTER_FORMAT_LABEL, !bWindowed );
|
---|
480 | m_Dialog.SetControlEnabled( DXUTSETTINGSDLG_RESOLUTION_LABEL, !bWindowed );
|
---|
481 | m_Dialog.SetControlEnabled( DXUTSETTINGSDLG_REFRESH_RATE_LABEL, !bWindowed );
|
---|
482 |
|
---|
483 | m_Dialog.SetControlEnabled( DXUTSETTINGSDLG_ADAPTER_FORMAT, !bWindowed );
|
---|
484 | m_Dialog.SetControlEnabled( DXUTSETTINGSDLG_RESOLUTION, !bWindowed );
|
---|
485 | m_Dialog.SetControlEnabled( DXUTSETTINGSDLG_REFRESH_RATE, !bWindowed );
|
---|
486 | m_Dialog.SetControlEnabled( DXUTSETTINGSDLG_DEVICECLIP, bWindowed );
|
---|
487 |
|
---|
488 | bool bDeviceClip = ( 0x0 != (g_DeviceSettings.pp.Flags & D3DPRESENTFLAG_DEVICECLIP) );
|
---|
489 |
|
---|
490 | // If windowed, get the appropriate adapter format from Direct3D
|
---|
491 | if( g_DeviceSettings.pp.Windowed )
|
---|
492 | {
|
---|
493 | IDirect3D9* pD3D = DXUTGetD3DObject();
|
---|
494 | if( pD3D == NULL )
|
---|
495 | return DXTRACE_ERR( L"DXUTGetD3DObject", E_FAIL );
|
---|
496 |
|
---|
497 | D3DDISPLAYMODE mode;
|
---|
498 | hr = pD3D->GetAdapterDisplayMode( g_DeviceSettings.AdapterOrdinal, &mode );
|
---|
499 | if( FAILED(hr) )
|
---|
500 | return DXTRACE_ERR( L"GetAdapterDisplayMode", hr );
|
---|
501 |
|
---|
502 | g_DeviceSettings.AdapterFormat = mode.Format;
|
---|
503 | g_DeviceSettings.pp.BackBufferWidth = mode.Width;
|
---|
504 | g_DeviceSettings.pp.BackBufferHeight = mode.Height;
|
---|
505 | g_DeviceSettings.pp.FullScreen_RefreshRateInHz = mode.RefreshRate;
|
---|
506 | }
|
---|
507 |
|
---|
508 | const D3DFORMAT adapterFormat = g_DeviceSettings.AdapterFormat;
|
---|
509 | const DWORD dwWidth = g_DeviceSettings.pp.BackBufferWidth;
|
---|
510 | const DWORD dwHeight = g_DeviceSettings.pp.BackBufferHeight;
|
---|
511 | const DWORD dwRefreshRate = g_DeviceSettings.pp.FullScreen_RefreshRateInHz;
|
---|
512 |
|
---|
513 | // DXUTSETTINGSDLG_DEVICECLIP
|
---|
514 | SetDeviceClip( bDeviceClip );
|
---|
515 |
|
---|
516 | // DXUTSETTINGSDLG_ADAPTER_FORMAT
|
---|
517 | CDXUTComboBox* pAdapterFormatComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_ADAPTER_FORMAT );
|
---|
518 | if( pAdapterFormatComboBox == NULL )
|
---|
519 | return E_FAIL;
|
---|
520 | pAdapterFormatComboBox->RemoveAllItems();
|
---|
521 |
|
---|
522 | CD3DEnumDeviceInfo* pDeviceInfo = GetCurrentDeviceInfo();
|
---|
523 | if( pDeviceInfo == NULL )
|
---|
524 | return E_FAIL;
|
---|
525 |
|
---|
526 | if( bWindowed )
|
---|
527 | {
|
---|
528 | AddAdapterFormat( adapterFormat );
|
---|
529 | }
|
---|
530 | else
|
---|
531 | {
|
---|
532 | for( int iSettingsCombo=0; iSettingsCombo < pDeviceInfo->deviceSettingsComboList.GetSize(); iSettingsCombo++ )
|
---|
533 | {
|
---|
534 | CD3DEnumDeviceSettingsCombo* pSettingsCombo = pDeviceInfo->deviceSettingsComboList.GetAt(iSettingsCombo);
|
---|
535 | AddAdapterFormat( pSettingsCombo->AdapterFormat );
|
---|
536 | }
|
---|
537 | }
|
---|
538 |
|
---|
539 | pAdapterFormatComboBox->SetSelectedByData( ULongToPtr(adapterFormat) );
|
---|
540 |
|
---|
541 | hr = OnAdapterFormatChanged();
|
---|
542 | if( FAILED(hr) )
|
---|
543 | return hr;
|
---|
544 |
|
---|
545 | // DXUTSETTINGSDLG_RESOLUTION
|
---|
546 | CDXUTComboBox* pResolutionComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_RESOLUTION );
|
---|
547 |
|
---|
548 | if( bWindowed )
|
---|
549 | {
|
---|
550 | pResolutionComboBox->RemoveAllItems();
|
---|
551 | AddResolution( dwWidth, dwHeight );
|
---|
552 | }
|
---|
553 |
|
---|
554 | pResolutionComboBox->SetSelectedByData( ULongToPtr( MAKELONG(dwWidth, dwHeight) ) );
|
---|
555 |
|
---|
556 | hr = OnResolutionChanged();
|
---|
557 | if( FAILED(hr) )
|
---|
558 | return hr;
|
---|
559 |
|
---|
560 | // DXUTSETTINGSDLG_REFRESH_RATE
|
---|
561 | CDXUTComboBox* pRefreshRateComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_REFRESH_RATE );
|
---|
562 |
|
---|
563 | if( bWindowed )
|
---|
564 | {
|
---|
565 | pRefreshRateComboBox->RemoveAllItems();
|
---|
566 | AddRefreshRate( dwRefreshRate );
|
---|
567 | }
|
---|
568 |
|
---|
569 | pRefreshRateComboBox->SetSelectedByData( ULongToPtr(dwRefreshRate) );
|
---|
570 |
|
---|
571 | hr = OnRefreshRateChanged();
|
---|
572 | if( FAILED(hr) )
|
---|
573 | return hr;
|
---|
574 |
|
---|
575 | return S_OK;
|
---|
576 | }
|
---|
577 |
|
---|
578 |
|
---|
579 | //-------------------------------------------------------------------------------------
|
---|
580 | HRESULT CD3DSettingsDlg::OnAdapterFormatChanged()
|
---|
581 | {
|
---|
582 | HRESULT hr = S_OK;
|
---|
583 |
|
---|
584 | // DXUTSETTINGSDLG_ADAPTER_FORMAT
|
---|
585 | D3DFORMAT adapterFormat = GetSelectedAdapterFormat();
|
---|
586 | g_DeviceSettings.AdapterFormat = adapterFormat;
|
---|
587 |
|
---|
588 | // DXUTSETTINGSDLG_RESOLUTION
|
---|
589 | CDXUTComboBox* pResolutionComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_RESOLUTION );
|
---|
590 | pResolutionComboBox->RemoveAllItems();
|
---|
591 |
|
---|
592 | CD3DEnumAdapterInfo* pAdapterInfo = GetCurrentAdapterInfo();
|
---|
593 | if( pAdapterInfo == NULL )
|
---|
594 | return E_FAIL;
|
---|
595 |
|
---|
596 | for( int idm = 0; idm < pAdapterInfo->displayModeList.GetSize(); idm++ )
|
---|
597 | {
|
---|
598 | D3DDISPLAYMODE DisplayMode = pAdapterInfo->displayModeList.GetAt( idm );
|
---|
599 |
|
---|
600 | if( DisplayMode.Format == adapterFormat )
|
---|
601 | AddResolution( DisplayMode.Width, DisplayMode.Height );
|
---|
602 | }
|
---|
603 |
|
---|
604 | const DWORD dwCurResolution = MAKELONG( g_DeviceSettings.pp.BackBufferWidth,
|
---|
605 | g_DeviceSettings.pp.BackBufferHeight );
|
---|
606 |
|
---|
607 | pResolutionComboBox->SetSelectedByData( ULongToPtr(dwCurResolution) );
|
---|
608 |
|
---|
609 | hr = OnResolutionChanged();
|
---|
610 | if( FAILED(hr) )
|
---|
611 | return hr;
|
---|
612 |
|
---|
613 | // DXUTSETTINGSDLG_BACK_BUFFER_FORMAT
|
---|
614 | CDXUTComboBox* pBackBufferFormatComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_BACK_BUFFER_FORMAT );
|
---|
615 | pBackBufferFormatComboBox->RemoveAllItems();
|
---|
616 |
|
---|
617 | CD3DEnumDeviceInfo* pDeviceInfo = GetCurrentDeviceInfo();
|
---|
618 | if( pDeviceInfo == NULL )
|
---|
619 | return E_FAIL;
|
---|
620 |
|
---|
621 | const BOOL bWindowed = IsWindowed();
|
---|
622 | bool bHasWindowedBackBuffer = false;
|
---|
623 |
|
---|
624 | for( int idc = 0; idc < pDeviceInfo->deviceSettingsComboList.GetSize(); idc++ )
|
---|
625 | {
|
---|
626 | CD3DEnumDeviceSettingsCombo* pDeviceCombo = pDeviceInfo->deviceSettingsComboList.GetAt( idc );
|
---|
627 | if( pDeviceCombo->Windowed == bWindowed &&
|
---|
628 | pDeviceCombo->AdapterFormat == g_DeviceSettings.AdapterFormat )
|
---|
629 | {
|
---|
630 | AddBackBufferFormat( pDeviceCombo->BackBufferFormat );
|
---|
631 | bHasWindowedBackBuffer = true;
|
---|
632 | }
|
---|
633 | }
|
---|
634 |
|
---|
635 | pBackBufferFormatComboBox->SetSelectedByData( ULongToPtr(g_DeviceSettings.pp.BackBufferFormat) );
|
---|
636 |
|
---|
637 | hr = OnBackBufferFormatChanged();
|
---|
638 | if( FAILED(hr) )
|
---|
639 | return hr;
|
---|
640 |
|
---|
641 | if( !bHasWindowedBackBuffer )
|
---|
642 | {
|
---|
643 | m_Dialog.SetControlEnabled( DXUTSETTINGSDLG_WINDOWED, false );
|
---|
644 |
|
---|
645 | if( g_DeviceSettings.pp.Windowed )
|
---|
646 | {
|
---|
647 | SetWindowed( false );
|
---|
648 |
|
---|
649 | hr = OnWindowedFullScreenChanged();
|
---|
650 | if( FAILED(hr) )
|
---|
651 | return hr;
|
---|
652 | }
|
---|
653 | }
|
---|
654 |
|
---|
655 | return S_OK;
|
---|
656 | }
|
---|
657 |
|
---|
658 |
|
---|
659 | //-------------------------------------------------------------------------------------
|
---|
660 | HRESULT CD3DSettingsDlg::OnResolutionChanged()
|
---|
661 | {
|
---|
662 | HRESULT hr = S_OK;
|
---|
663 |
|
---|
664 | CD3DEnumAdapterInfo* pAdapterInfo = GetCurrentAdapterInfo();
|
---|
665 | if( pAdapterInfo == NULL )
|
---|
666 | return E_FAIL;
|
---|
667 |
|
---|
668 | // Set resolution
|
---|
669 | DWORD dwWidth, dwHeight;
|
---|
670 | GetSelectedResolution( &dwWidth, &dwHeight );
|
---|
671 | g_DeviceSettings.pp.BackBufferWidth = dwWidth;
|
---|
672 | g_DeviceSettings.pp.BackBufferHeight = dwHeight;
|
---|
673 |
|
---|
674 | DWORD dwRefreshRate = g_DeviceSettings.pp.FullScreen_RefreshRateInHz;
|
---|
675 |
|
---|
676 | // Update the refresh rate list
|
---|
677 | CDXUTComboBox* pRefreshRateComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_REFRESH_RATE );
|
---|
678 | pRefreshRateComboBox->RemoveAllItems();
|
---|
679 |
|
---|
680 | D3DFORMAT adapterFormat = g_DeviceSettings.AdapterFormat;
|
---|
681 | for( int idm = 0; idm < pAdapterInfo->displayModeList.GetSize(); idm++ )
|
---|
682 | {
|
---|
683 | D3DDISPLAYMODE displayMode = pAdapterInfo->displayModeList.GetAt( idm );
|
---|
684 |
|
---|
685 | if( displayMode.Format == adapterFormat &&
|
---|
686 | displayMode.Width == dwWidth &&
|
---|
687 | displayMode.Height == dwHeight )
|
---|
688 | {
|
---|
689 | AddRefreshRate( displayMode.RefreshRate );
|
---|
690 | }
|
---|
691 | }
|
---|
692 |
|
---|
693 | pRefreshRateComboBox->SetSelectedByData( ULongToPtr(dwRefreshRate) );
|
---|
694 |
|
---|
695 | hr = OnRefreshRateChanged();
|
---|
696 | if( FAILED(hr) )
|
---|
697 | return hr;
|
---|
698 |
|
---|
699 | return S_OK;
|
---|
700 | }
|
---|
701 |
|
---|
702 |
|
---|
703 | //-------------------------------------------------------------------------------------
|
---|
704 | HRESULT CD3DSettingsDlg::OnRefreshRateChanged()
|
---|
705 | {
|
---|
706 | // Set refresh rate
|
---|
707 | g_DeviceSettings.pp.FullScreen_RefreshRateInHz = GetSelectedRefreshRate();
|
---|
708 |
|
---|
709 | return S_OK;
|
---|
710 | }
|
---|
711 |
|
---|
712 |
|
---|
713 | //-------------------------------------------------------------------------------------
|
---|
714 | HRESULT CD3DSettingsDlg::OnBackBufferFormatChanged()
|
---|
715 | {
|
---|
716 | HRESULT hr = S_OK;
|
---|
717 |
|
---|
718 | g_DeviceSettings.pp.BackBufferFormat = GetSelectedBackBufferFormat();
|
---|
719 |
|
---|
720 | D3DFORMAT adapterFormat = g_DeviceSettings.AdapterFormat;
|
---|
721 | D3DFORMAT backBufferFormat = g_DeviceSettings.pp.BackBufferFormat;
|
---|
722 |
|
---|
723 | CD3DEnumDeviceInfo* pDeviceInfo = GetCurrentDeviceInfo();
|
---|
724 | if( pDeviceInfo == NULL )
|
---|
725 | return E_FAIL;
|
---|
726 |
|
---|
727 | bool bAllowSoftwareVP, bAllowHardwareVP, bAllowPureHardwareVP, bAllowMixedVP;
|
---|
728 | DXUTGetEnumeration()->GetPossibleVertexProcessingList( &bAllowSoftwareVP, &bAllowHardwareVP,
|
---|
729 | &bAllowPureHardwareVP, &bAllowMixedVP );
|
---|
730 |
|
---|
731 | for( int idc=0; idc < pDeviceInfo->deviceSettingsComboList.GetSize(); idc++ )
|
---|
732 | {
|
---|
733 | CD3DEnumDeviceSettingsCombo* pDeviceCombo = pDeviceInfo->deviceSettingsComboList.GetAt( idc );
|
---|
734 |
|
---|
735 | if( pDeviceCombo->Windowed == (g_DeviceSettings.pp.Windowed == TRUE) &&
|
---|
736 | pDeviceCombo->AdapterFormat == adapterFormat &&
|
---|
737 | pDeviceCombo->BackBufferFormat == backBufferFormat )
|
---|
738 | {
|
---|
739 | CDXUTComboBox* pDepthStencilComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_DEPTH_STENCIL );
|
---|
740 | pDepthStencilComboBox->RemoveAllItems();
|
---|
741 | pDepthStencilComboBox->SetEnabled( (g_DeviceSettings.pp.EnableAutoDepthStencil == TRUE) );
|
---|
742 |
|
---|
743 | if( g_DeviceSettings.pp.EnableAutoDepthStencil )
|
---|
744 | {
|
---|
745 | for( int ifmt=0; ifmt < pDeviceCombo->depthStencilFormatList.GetSize(); ifmt++ )
|
---|
746 | {
|
---|
747 | D3DFORMAT fmt = pDeviceCombo->depthStencilFormatList.GetAt( ifmt );
|
---|
748 |
|
---|
749 | AddDepthStencilBufferFormat( fmt );
|
---|
750 | }
|
---|
751 |
|
---|
752 | pDepthStencilComboBox->SetSelectedByData( ULongToPtr(g_DeviceSettings.pp.AutoDepthStencilFormat) );
|
---|
753 | }
|
---|
754 | else
|
---|
755 | {
|
---|
756 | if( !pDepthStencilComboBox->ContainsItem( L"(not used)" ) )
|
---|
757 | pDepthStencilComboBox->AddItem( L"(not used)", NULL );
|
---|
758 | }
|
---|
759 |
|
---|
760 | hr = OnDepthStencilBufferFormatChanged();
|
---|
761 | if( FAILED(hr) )
|
---|
762 | return hr;
|
---|
763 |
|
---|
764 | CDXUTComboBox* pVertexProcessingComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_VERTEX_PROCESSING );
|
---|
765 | pVertexProcessingComboBox->RemoveAllItems();
|
---|
766 |
|
---|
767 | // Add valid vertex processing types
|
---|
768 | if( bAllowSoftwareVP )
|
---|
769 | AddVertexProcessingType( D3DCREATE_SOFTWARE_VERTEXPROCESSING );
|
---|
770 |
|
---|
771 | if( bAllowHardwareVP && pDeviceInfo->Caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT )
|
---|
772 | AddVertexProcessingType( D3DCREATE_HARDWARE_VERTEXPROCESSING );
|
---|
773 |
|
---|
774 | if( bAllowPureHardwareVP && pDeviceInfo->Caps.DevCaps & D3DDEVCAPS_PUREDEVICE )
|
---|
775 | AddVertexProcessingType( D3DCREATE_PUREDEVICE );
|
---|
776 |
|
---|
777 | if( bAllowMixedVP && pDeviceInfo->Caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT )
|
---|
778 | AddVertexProcessingType( D3DCREATE_MIXED_VERTEXPROCESSING );
|
---|
779 |
|
---|
780 | if( g_DeviceSettings.BehaviorFlags & D3DCREATE_PUREDEVICE )
|
---|
781 | pVertexProcessingComboBox->SetSelectedByData( ULongToPtr(D3DCREATE_PUREDEVICE) );
|
---|
782 | else if( g_DeviceSettings.BehaviorFlags & D3DCREATE_SOFTWARE_VERTEXPROCESSING )
|
---|
783 | pVertexProcessingComboBox->SetSelectedByData( ULongToPtr(D3DCREATE_SOFTWARE_VERTEXPROCESSING) );
|
---|
784 | else if( g_DeviceSettings.BehaviorFlags & D3DCREATE_HARDWARE_VERTEXPROCESSING )
|
---|
785 | pVertexProcessingComboBox->SetSelectedByData( ULongToPtr(D3DCREATE_HARDWARE_VERTEXPROCESSING) );
|
---|
786 | else if( g_DeviceSettings.BehaviorFlags & D3DCREATE_MIXED_VERTEXPROCESSING )
|
---|
787 | pVertexProcessingComboBox->SetSelectedByData( ULongToPtr(D3DCREATE_MIXED_VERTEXPROCESSING) );
|
---|
788 |
|
---|
789 | hr = OnVertexProcessingChanged();
|
---|
790 | if( FAILED(hr) )
|
---|
791 | return hr;
|
---|
792 |
|
---|
793 | CDXUTComboBox* pPresentIntervalComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_PRESENT_INTERVAL );
|
---|
794 | pPresentIntervalComboBox->RemoveAllItems();
|
---|
795 |
|
---|
796 | for( int ipi=0; ipi < pDeviceCombo->presentIntervalList.GetSize(); ipi++ )
|
---|
797 | {
|
---|
798 | UINT presentInterval = pDeviceCombo->presentIntervalList.GetAt( ipi );
|
---|
799 |
|
---|
800 | AddPresentInterval( presentInterval );
|
---|
801 | }
|
---|
802 |
|
---|
803 | pPresentIntervalComboBox->SetSelectedByData( ULongToPtr( g_DeviceSettings.pp.PresentationInterval ) );
|
---|
804 |
|
---|
805 | hr = OnPresentIntervalChanged();
|
---|
806 | if( FAILED(hr) )
|
---|
807 | return hr;
|
---|
808 | }
|
---|
809 | }
|
---|
810 |
|
---|
811 | return S_OK;
|
---|
812 | }
|
---|
813 |
|
---|
814 |
|
---|
815 | //-------------------------------------------------------------------------------------
|
---|
816 | HRESULT CD3DSettingsDlg::OnDepthStencilBufferFormatChanged()
|
---|
817 | {
|
---|
818 | HRESULT hr = S_OK;
|
---|
819 |
|
---|
820 | D3DFORMAT depthStencilBufferFormat = GetSelectedDepthStencilBufferFormat();
|
---|
821 |
|
---|
822 | if( g_DeviceSettings.pp.EnableAutoDepthStencil )
|
---|
823 | g_DeviceSettings.pp.AutoDepthStencilFormat = depthStencilBufferFormat;
|
---|
824 |
|
---|
825 | CD3DEnumDeviceSettingsCombo* pDeviceSettingsCombo = GetCurrentDeviceSettingsCombo();
|
---|
826 | if( pDeviceSettingsCombo == NULL )
|
---|
827 | return E_FAIL;
|
---|
828 |
|
---|
829 | CDXUTComboBox* pMultisampleTypeCombo = m_Dialog.GetComboBox( DXUTSETTINGSDLG_MULTISAMPLE_TYPE );
|
---|
830 | pMultisampleTypeCombo->RemoveAllItems();
|
---|
831 |
|
---|
832 | for( int ims=0; ims < pDeviceSettingsCombo->multiSampleTypeList.GetSize(); ims++ )
|
---|
833 | {
|
---|
834 | D3DMULTISAMPLE_TYPE msType = pDeviceSettingsCombo->multiSampleTypeList.GetAt( ims );
|
---|
835 |
|
---|
836 | bool bConflictFound = false;
|
---|
837 | for( int iConf = 0; iConf < pDeviceSettingsCombo->DSMSConflictList.GetSize(); iConf++ )
|
---|
838 | {
|
---|
839 | CD3DEnumDSMSConflict DSMSConf = pDeviceSettingsCombo->DSMSConflictList.GetAt( iConf );
|
---|
840 | if( DSMSConf.DSFormat == depthStencilBufferFormat &&
|
---|
841 | DSMSConf.MSType == msType )
|
---|
842 | {
|
---|
843 | bConflictFound = true;
|
---|
844 | break;
|
---|
845 | }
|
---|
846 | }
|
---|
847 |
|
---|
848 | if( !bConflictFound )
|
---|
849 | AddMultisampleType( msType );
|
---|
850 | }
|
---|
851 |
|
---|
852 | CDXUTComboBox* pMultisampleQualityCombo = m_Dialog.GetComboBox( DXUTSETTINGSDLG_MULTISAMPLE_TYPE );
|
---|
853 | pMultisampleQualityCombo->SetSelectedByData( ULongToPtr(g_DeviceSettings.pp.MultiSampleType) );
|
---|
854 |
|
---|
855 | hr = OnMultisampleTypeChanged();
|
---|
856 | if( FAILED(hr) )
|
---|
857 | return hr;
|
---|
858 |
|
---|
859 | return S_OK;
|
---|
860 | }
|
---|
861 |
|
---|
862 |
|
---|
863 | //-------------------------------------------------------------------------------------
|
---|
864 | HRESULT CD3DSettingsDlg::OnMultisampleTypeChanged()
|
---|
865 | {
|
---|
866 | HRESULT hr = S_OK;
|
---|
867 |
|
---|
868 | D3DMULTISAMPLE_TYPE multisampleType = GetSelectedMultisampleType();
|
---|
869 | g_DeviceSettings.pp.MultiSampleType = multisampleType;
|
---|
870 |
|
---|
871 | CD3DEnumDeviceSettingsCombo* pDeviceSettingsCombo = GetCurrentDeviceSettingsCombo();
|
---|
872 | if( pDeviceSettingsCombo == NULL )
|
---|
873 | return E_FAIL;
|
---|
874 |
|
---|
875 | DWORD dwMaxQuality = 0;
|
---|
876 | for( int iType = 0; iType < pDeviceSettingsCombo->multiSampleTypeList.GetSize(); iType++ )
|
---|
877 | {
|
---|
878 | D3DMULTISAMPLE_TYPE msType = pDeviceSettingsCombo->multiSampleTypeList.GetAt( iType );
|
---|
879 | if( msType == multisampleType )
|
---|
880 | {
|
---|
881 | dwMaxQuality = pDeviceSettingsCombo->multiSampleQualityList.GetAt( iType );
|
---|
882 | break;
|
---|
883 | }
|
---|
884 | }
|
---|
885 |
|
---|
886 | // DXUTSETTINGSDLG_MULTISAMPLE_QUALITY
|
---|
887 | CDXUTComboBox* pMultisampleQualityCombo = m_Dialog.GetComboBox( DXUTSETTINGSDLG_MULTISAMPLE_QUALITY );
|
---|
888 | pMultisampleQualityCombo->RemoveAllItems();
|
---|
889 |
|
---|
890 | for( UINT iQuality = 0; iQuality < dwMaxQuality; iQuality++ )
|
---|
891 | {
|
---|
892 | AddMultisampleQuality( iQuality );
|
---|
893 | }
|
---|
894 |
|
---|
895 | pMultisampleQualityCombo->SetSelectedByData( ULongToPtr(g_DeviceSettings.pp.MultiSampleQuality) );
|
---|
896 |
|
---|
897 | hr = OnMultisampleQualityChanged();
|
---|
898 | if( FAILED(hr) )
|
---|
899 | return hr;
|
---|
900 |
|
---|
901 | return S_OK;
|
---|
902 | }
|
---|
903 |
|
---|
904 |
|
---|
905 | //-------------------------------------------------------------------------------------
|
---|
906 | HRESULT CD3DSettingsDlg::OnMultisampleQualityChanged()
|
---|
907 | {
|
---|
908 | g_DeviceSettings.pp.MultiSampleQuality = GetSelectedMultisampleQuality();
|
---|
909 |
|
---|
910 | return S_OK;
|
---|
911 | }
|
---|
912 |
|
---|
913 |
|
---|
914 | //-------------------------------------------------------------------------------------
|
---|
915 | HRESULT CD3DSettingsDlg::OnVertexProcessingChanged()
|
---|
916 | {
|
---|
917 | DWORD dwBehavior = g_DeviceSettings.BehaviorFlags;
|
---|
918 |
|
---|
919 | // Clear vertex processing flags
|
---|
920 | dwBehavior &= ~D3DCREATE_HARDWARE_VERTEXPROCESSING;
|
---|
921 | dwBehavior &= ~D3DCREATE_SOFTWARE_VERTEXPROCESSING;
|
---|
922 | dwBehavior &= ~D3DCREATE_MIXED_VERTEXPROCESSING;
|
---|
923 | dwBehavior &= ~D3DCREATE_PUREDEVICE;
|
---|
924 |
|
---|
925 | // Determine new flags
|
---|
926 | DWORD dwNewFlags = GetSelectedVertexProcessingType();
|
---|
927 | if( dwNewFlags & D3DCREATE_PUREDEVICE )
|
---|
928 | dwNewFlags |= D3DCREATE_HARDWARE_VERTEXPROCESSING;
|
---|
929 |
|
---|
930 | // Make changes
|
---|
931 | g_DeviceSettings.BehaviorFlags = dwBehavior | dwNewFlags;
|
---|
932 |
|
---|
933 | return S_OK;
|
---|
934 | }
|
---|
935 |
|
---|
936 |
|
---|
937 | //-------------------------------------------------------------------------------------
|
---|
938 | HRESULT CD3DSettingsDlg::OnPresentIntervalChanged()
|
---|
939 | {
|
---|
940 | g_DeviceSettings.pp.PresentationInterval = GetSelectedPresentInterval();
|
---|
941 |
|
---|
942 | return S_OK;
|
---|
943 | }
|
---|
944 |
|
---|
945 |
|
---|
946 | //-------------------------------------------------------------------------------------
|
---|
947 | HRESULT CD3DSettingsDlg::OnDeviceClipChanged()
|
---|
948 | {
|
---|
949 | if( IsDeviceClip() )
|
---|
950 | g_DeviceSettings.pp.Flags |= D3DPRESENTFLAG_DEVICECLIP;
|
---|
951 | else
|
---|
952 | g_DeviceSettings.pp.Flags &= ~D3DPRESENTFLAG_DEVICECLIP;
|
---|
953 |
|
---|
954 | return S_OK;
|
---|
955 | }
|
---|
956 |
|
---|
957 |
|
---|
958 | //-------------------------------------------------------------------------------------
|
---|
959 | void CD3DSettingsDlg::AddAdapter( const WCHAR* strDescription, UINT iAdapter )
|
---|
960 | {
|
---|
961 | CDXUTComboBox* pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_ADAPTER );
|
---|
962 |
|
---|
963 | if( !pComboBox->ContainsItem( strDescription ) )
|
---|
964 | pComboBox->AddItem( strDescription, ULongToPtr(iAdapter) );
|
---|
965 | }
|
---|
966 |
|
---|
967 |
|
---|
968 | //-------------------------------------------------------------------------------------
|
---|
969 | UINT CD3DSettingsDlg::GetSelectedAdapter()
|
---|
970 | {
|
---|
971 | CDXUTComboBox* pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_ADAPTER );
|
---|
972 |
|
---|
973 | return PtrToUlong( pComboBox->GetSelectedData() );
|
---|
974 | }
|
---|
975 |
|
---|
976 |
|
---|
977 | //-------------------------------------------------------------------------------------
|
---|
978 | void CD3DSettingsDlg::AddDeviceType( D3DDEVTYPE devType )
|
---|
979 | {
|
---|
980 | CDXUTComboBox* pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_DEVICE_TYPE );
|
---|
981 |
|
---|
982 | if( !pComboBox->ContainsItem( DXUTD3DDeviceTypeToString(devType) ) )
|
---|
983 | pComboBox->AddItem( DXUTD3DDeviceTypeToString(devType), ULongToPtr(devType) );
|
---|
984 | }
|
---|
985 |
|
---|
986 |
|
---|
987 | //-------------------------------------------------------------------------------------
|
---|
988 | D3DDEVTYPE CD3DSettingsDlg::GetSelectedDeviceType()
|
---|
989 | {
|
---|
990 | CDXUTComboBox* pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_DEVICE_TYPE );
|
---|
991 |
|
---|
992 | return (D3DDEVTYPE) PtrToUlong( pComboBox->GetSelectedData() );
|
---|
993 | }
|
---|
994 |
|
---|
995 |
|
---|
996 | //-------------------------------------------------------------------------------------
|
---|
997 | void CD3DSettingsDlg::SetWindowed( bool bWindowed )
|
---|
998 | {
|
---|
999 | CDXUTRadioButton* pRadioButton = m_Dialog.GetRadioButton( DXUTSETTINGSDLG_WINDOWED );
|
---|
1000 | pRadioButton->SetChecked( bWindowed );
|
---|
1001 |
|
---|
1002 | pRadioButton = m_Dialog.GetRadioButton( DXUTSETTINGSDLG_FULLSCREEN );
|
---|
1003 | pRadioButton->SetChecked( !bWindowed );
|
---|
1004 | }
|
---|
1005 |
|
---|
1006 |
|
---|
1007 | //-------------------------------------------------------------------------------------
|
---|
1008 | bool CD3DSettingsDlg::IsWindowed()
|
---|
1009 | {
|
---|
1010 | CDXUTRadioButton* pRadioButton = m_Dialog.GetRadioButton( DXUTSETTINGSDLG_WINDOWED );
|
---|
1011 | return pRadioButton->GetChecked();
|
---|
1012 | }
|
---|
1013 |
|
---|
1014 |
|
---|
1015 | //-------------------------------------------------------------------------------------
|
---|
1016 | void CD3DSettingsDlg::AddAdapterFormat( D3DFORMAT format )
|
---|
1017 | {
|
---|
1018 | CDXUTComboBox* pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_ADAPTER_FORMAT );
|
---|
1019 |
|
---|
1020 | if( !pComboBox->ContainsItem( DXUTD3DFormatToString(format, TRUE) ) )
|
---|
1021 | pComboBox->AddItem( DXUTD3DFormatToString(format, TRUE), ULongToPtr( format ) );
|
---|
1022 | }
|
---|
1023 |
|
---|
1024 |
|
---|
1025 | //-------------------------------------------------------------------------------------
|
---|
1026 | D3DFORMAT CD3DSettingsDlg::GetSelectedAdapterFormat()
|
---|
1027 | {
|
---|
1028 | CDXUTComboBox* pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_ADAPTER_FORMAT );
|
---|
1029 |
|
---|
1030 | return (D3DFORMAT) PtrToUlong( pComboBox->GetSelectedData() );
|
---|
1031 | }
|
---|
1032 |
|
---|
1033 |
|
---|
1034 | //-------------------------------------------------------------------------------------
|
---|
1035 | void CD3DSettingsDlg::AddResolution( DWORD dwWidth, DWORD dwHeight )
|
---|
1036 | {
|
---|
1037 | CDXUTComboBox* pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_RESOLUTION );
|
---|
1038 |
|
---|
1039 | DWORD dwResolutionData;
|
---|
1040 | WCHAR strResolution[50];
|
---|
1041 | dwResolutionData = MAKELONG( dwWidth, dwHeight );
|
---|
1042 | StringCchPrintf( strResolution, 50, L"%d by %d", dwWidth, dwHeight );
|
---|
1043 |
|
---|
1044 | if( !pComboBox->ContainsItem( strResolution ) )
|
---|
1045 | pComboBox->AddItem( strResolution, ULongToPtr( dwResolutionData ) );
|
---|
1046 | }
|
---|
1047 |
|
---|
1048 |
|
---|
1049 | //-------------------------------------------------------------------------------------
|
---|
1050 | void CD3DSettingsDlg::GetSelectedResolution( DWORD* pdwWidth, DWORD* pdwHeight )
|
---|
1051 | {
|
---|
1052 | CDXUTComboBox* pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_RESOLUTION );
|
---|
1053 |
|
---|
1054 | DWORD dwResolution = PtrToUlong( pComboBox->GetSelectedData() );
|
---|
1055 |
|
---|
1056 | *pdwWidth = LOWORD( dwResolution );
|
---|
1057 | *pdwHeight = HIWORD( dwResolution );
|
---|
1058 | }
|
---|
1059 |
|
---|
1060 |
|
---|
1061 | //-------------------------------------------------------------------------------------
|
---|
1062 | void CD3DSettingsDlg::AddRefreshRate( DWORD dwRate )
|
---|
1063 | {
|
---|
1064 | CDXUTComboBox* pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_REFRESH_RATE );
|
---|
1065 |
|
---|
1066 | WCHAR strRefreshRate[50];
|
---|
1067 |
|
---|
1068 | if( dwRate == 0 )
|
---|
1069 | StringCchCopy( strRefreshRate, 50, L"Default Rate" );
|
---|
1070 | else
|
---|
1071 | StringCchPrintf( strRefreshRate, 50, L"%d Hz", dwRate );
|
---|
1072 |
|
---|
1073 | if( !pComboBox->ContainsItem( strRefreshRate ) )
|
---|
1074 | pComboBox->AddItem( strRefreshRate, ULongToPtr(dwRate) );
|
---|
1075 | }
|
---|
1076 |
|
---|
1077 |
|
---|
1078 | //-------------------------------------------------------------------------------------
|
---|
1079 | DWORD CD3DSettingsDlg::GetSelectedRefreshRate()
|
---|
1080 | {
|
---|
1081 | CDXUTComboBox* pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_REFRESH_RATE );
|
---|
1082 |
|
---|
1083 | return PtrToUlong( pComboBox->GetSelectedData() );
|
---|
1084 | }
|
---|
1085 |
|
---|
1086 |
|
---|
1087 | //-------------------------------------------------------------------------------------
|
---|
1088 | void CD3DSettingsDlg::AddBackBufferFormat( D3DFORMAT format )
|
---|
1089 | {
|
---|
1090 | CDXUTComboBox* pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_BACK_BUFFER_FORMAT );
|
---|
1091 |
|
---|
1092 | if( !pComboBox->ContainsItem( DXUTD3DFormatToString(format, TRUE) ) )
|
---|
1093 | pComboBox->AddItem( DXUTD3DFormatToString(format, TRUE), ULongToPtr( format ) );
|
---|
1094 | }
|
---|
1095 |
|
---|
1096 |
|
---|
1097 | //-------------------------------------------------------------------------------------
|
---|
1098 | D3DFORMAT CD3DSettingsDlg::GetSelectedBackBufferFormat()
|
---|
1099 | {
|
---|
1100 | CDXUTComboBox* pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_BACK_BUFFER_FORMAT );
|
---|
1101 |
|
---|
1102 | return (D3DFORMAT) PtrToUlong( pComboBox->GetSelectedData() );
|
---|
1103 | }
|
---|
1104 |
|
---|
1105 |
|
---|
1106 | //-------------------------------------------------------------------------------------
|
---|
1107 | void CD3DSettingsDlg::AddDepthStencilBufferFormat( D3DFORMAT format )
|
---|
1108 | {
|
---|
1109 | CDXUTComboBox* pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_DEPTH_STENCIL );
|
---|
1110 |
|
---|
1111 | if( !pComboBox->ContainsItem( DXUTD3DFormatToString(format, TRUE) ) )
|
---|
1112 | pComboBox->AddItem( DXUTD3DFormatToString(format, TRUE), ULongToPtr(format) );
|
---|
1113 | }
|
---|
1114 |
|
---|
1115 |
|
---|
1116 | //-------------------------------------------------------------------------------------
|
---|
1117 | D3DFORMAT CD3DSettingsDlg::GetSelectedDepthStencilBufferFormat()
|
---|
1118 | {
|
---|
1119 | CDXUTComboBox* pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_DEPTH_STENCIL );
|
---|
1120 |
|
---|
1121 | return (D3DFORMAT) PtrToUlong( pComboBox->GetSelectedData() );
|
---|
1122 | }
|
---|
1123 |
|
---|
1124 |
|
---|
1125 | //-------------------------------------------------------------------------------------
|
---|
1126 | void CD3DSettingsDlg::AddMultisampleType( D3DMULTISAMPLE_TYPE type )
|
---|
1127 | {
|
---|
1128 | CDXUTComboBox* pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_MULTISAMPLE_TYPE );
|
---|
1129 |
|
---|
1130 | if( !pComboBox->ContainsItem( DXUTMultisampleTypeToString(type) ) )
|
---|
1131 | pComboBox->AddItem( DXUTMultisampleTypeToString(type), ULongToPtr(type) );
|
---|
1132 | }
|
---|
1133 |
|
---|
1134 |
|
---|
1135 | //-------------------------------------------------------------------------------------
|
---|
1136 | D3DMULTISAMPLE_TYPE CD3DSettingsDlg::GetSelectedMultisampleType()
|
---|
1137 | {
|
---|
1138 | CDXUTComboBox* pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_MULTISAMPLE_TYPE );
|
---|
1139 |
|
---|
1140 | return (D3DMULTISAMPLE_TYPE) PtrToUlong( pComboBox->GetSelectedData() );
|
---|
1141 | }
|
---|
1142 |
|
---|
1143 |
|
---|
1144 | //-------------------------------------------------------------------------------------
|
---|
1145 | void CD3DSettingsDlg::AddMultisampleQuality( DWORD dwQuality )
|
---|
1146 | {
|
---|
1147 | CDXUTComboBox* pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_MULTISAMPLE_QUALITY );
|
---|
1148 |
|
---|
1149 | WCHAR strQuality[50];
|
---|
1150 | StringCchPrintf( strQuality, 50, L"%d", dwQuality );
|
---|
1151 |
|
---|
1152 | if( !pComboBox->ContainsItem( strQuality ) )
|
---|
1153 | pComboBox->AddItem( strQuality, ULongToPtr(dwQuality) );
|
---|
1154 | }
|
---|
1155 |
|
---|
1156 |
|
---|
1157 | //-------------------------------------------------------------------------------------
|
---|
1158 | DWORD CD3DSettingsDlg::GetSelectedMultisampleQuality()
|
---|
1159 | {
|
---|
1160 | CDXUTComboBox* pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_MULTISAMPLE_QUALITY );
|
---|
1161 |
|
---|
1162 | return PtrToUlong( pComboBox->GetSelectedData() );
|
---|
1163 | }
|
---|
1164 |
|
---|
1165 |
|
---|
1166 | //-------------------------------------------------------------------------------------
|
---|
1167 | void CD3DSettingsDlg::AddVertexProcessingType( DWORD dwType )
|
---|
1168 | {
|
---|
1169 | CDXUTComboBox* pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_VERTEX_PROCESSING );
|
---|
1170 |
|
---|
1171 | if( !pComboBox->ContainsItem( DXUTVertexProcessingTypeToString(dwType) ) )
|
---|
1172 | pComboBox->AddItem( DXUTVertexProcessingTypeToString(dwType), ULongToPtr(dwType) );
|
---|
1173 | }
|
---|
1174 |
|
---|
1175 |
|
---|
1176 | //-------------------------------------------------------------------------------------
|
---|
1177 | DWORD CD3DSettingsDlg::GetSelectedVertexProcessingType()
|
---|
1178 | {
|
---|
1179 | CDXUTComboBox* pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_VERTEX_PROCESSING );
|
---|
1180 |
|
---|
1181 | return PtrToUlong( pComboBox->GetSelectedData() );
|
---|
1182 | }
|
---|
1183 |
|
---|
1184 |
|
---|
1185 | //-------------------------------------------------------------------------------------
|
---|
1186 | void CD3DSettingsDlg::AddPresentInterval( DWORD dwInterval )
|
---|
1187 | {
|
---|
1188 | CDXUTComboBox* pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_PRESENT_INTERVAL );
|
---|
1189 |
|
---|
1190 | if( !pComboBox->ContainsItem( DXUTPresentIntervalToString(dwInterval) ) )
|
---|
1191 | pComboBox->AddItem( DXUTPresentIntervalToString(dwInterval), ULongToPtr(dwInterval) );
|
---|
1192 | }
|
---|
1193 |
|
---|
1194 |
|
---|
1195 | //-------------------------------------------------------------------------------------
|
---|
1196 | DWORD CD3DSettingsDlg::GetSelectedPresentInterval()
|
---|
1197 | {
|
---|
1198 | CDXUTComboBox* pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_PRESENT_INTERVAL );
|
---|
1199 |
|
---|
1200 | return PtrToUlong( pComboBox->GetSelectedData() );
|
---|
1201 | }
|
---|
1202 |
|
---|
1203 |
|
---|
1204 | //-------------------------------------------------------------------------------------
|
---|
1205 | void CD3DSettingsDlg::SetDeviceClip( bool bDeviceClip )
|
---|
1206 | {
|
---|
1207 | CDXUTCheckBox* pCheckBox = m_Dialog.GetCheckBox( DXUTSETTINGSDLG_DEVICECLIP );
|
---|
1208 | pCheckBox->SetChecked( bDeviceClip );
|
---|
1209 | }
|
---|
1210 |
|
---|
1211 |
|
---|
1212 | //-------------------------------------------------------------------------------------
|
---|
1213 | bool CD3DSettingsDlg::IsDeviceClip()
|
---|
1214 | {
|
---|
1215 | CDXUTCheckBox* pCheckBox = m_Dialog.GetCheckBox( DXUTSETTINGSDLG_DEVICECLIP );
|
---|
1216 | return pCheckBox->GetChecked();
|
---|
1217 | }
|
---|
1218 |
|
---|
1219 |
|
---|
1220 | //--------------------------------------------------------------------------------------
|
---|
1221 | // Returns the string for the given D3DDEVTYPE.
|
---|
1222 | //--------------------------------------------------------------------------------------
|
---|
1223 | WCHAR* DXUTD3DDeviceTypeToString(D3DDEVTYPE devType)
|
---|
1224 | {
|
---|
1225 | switch (devType)
|
---|
1226 | {
|
---|
1227 | case D3DDEVTYPE_HAL: return L"D3DDEVTYPE_HAL";
|
---|
1228 | case D3DDEVTYPE_SW: return L"D3DDEVTYPE_SW";
|
---|
1229 | case D3DDEVTYPE_REF: return L"D3DDEVTYPE_REF";
|
---|
1230 | default: return L"Unknown devType";
|
---|
1231 | }
|
---|
1232 | }
|
---|
1233 |
|
---|
1234 |
|
---|
1235 | //--------------------------------------------------------------------------------------
|
---|
1236 | // Returns the string for the given D3DMULTISAMPLE_TYPE.
|
---|
1237 | //--------------------------------------------------------------------------------------
|
---|
1238 | WCHAR* DXUTMultisampleTypeToString(D3DMULTISAMPLE_TYPE MultiSampleType)
|
---|
1239 | {
|
---|
1240 | switch (MultiSampleType)
|
---|
1241 | {
|
---|
1242 | case D3DMULTISAMPLE_NONE: return L"D3DMULTISAMPLE_NONE";
|
---|
1243 | case D3DMULTISAMPLE_NONMASKABLE: return L"D3DMULTISAMPLE_NONMASKABLE";
|
---|
1244 | case D3DMULTISAMPLE_2_SAMPLES: return L"D3DMULTISAMPLE_2_SAMPLES";
|
---|
1245 | case D3DMULTISAMPLE_3_SAMPLES: return L"D3DMULTISAMPLE_3_SAMPLES";
|
---|
1246 | case D3DMULTISAMPLE_4_SAMPLES: return L"D3DMULTISAMPLE_4_SAMPLES";
|
---|
1247 | case D3DMULTISAMPLE_5_SAMPLES: return L"D3DMULTISAMPLE_5_SAMPLES";
|
---|
1248 | case D3DMULTISAMPLE_6_SAMPLES: return L"D3DMULTISAMPLE_6_SAMPLES";
|
---|
1249 | case D3DMULTISAMPLE_7_SAMPLES: return L"D3DMULTISAMPLE_7_SAMPLES";
|
---|
1250 | case D3DMULTISAMPLE_8_SAMPLES: return L"D3DMULTISAMPLE_8_SAMPLES";
|
---|
1251 | case D3DMULTISAMPLE_9_SAMPLES: return L"D3DMULTISAMPLE_9_SAMPLES";
|
---|
1252 | case D3DMULTISAMPLE_10_SAMPLES: return L"D3DMULTISAMPLE_10_SAMPLES";
|
---|
1253 | case D3DMULTISAMPLE_11_SAMPLES: return L"D3DMULTISAMPLE_11_SAMPLES";
|
---|
1254 | case D3DMULTISAMPLE_12_SAMPLES: return L"D3DMULTISAMPLE_12_SAMPLES";
|
---|
1255 | case D3DMULTISAMPLE_13_SAMPLES: return L"D3DMULTISAMPLE_13_SAMPLES";
|
---|
1256 | case D3DMULTISAMPLE_14_SAMPLES: return L"D3DMULTISAMPLE_14_SAMPLES";
|
---|
1257 | case D3DMULTISAMPLE_15_SAMPLES: return L"D3DMULTISAMPLE_15_SAMPLES";
|
---|
1258 | case D3DMULTISAMPLE_16_SAMPLES: return L"D3DMULTISAMPLE_16_SAMPLES";
|
---|
1259 | default: return L"Unknown Multisample Type";
|
---|
1260 | }
|
---|
1261 | }
|
---|
1262 |
|
---|
1263 |
|
---|
1264 | //--------------------------------------------------------------------------------------
|
---|
1265 | // Returns the string for the given vertex processing type
|
---|
1266 | //--------------------------------------------------------------------------------------
|
---|
1267 | WCHAR* DXUTVertexProcessingTypeToString(DWORD vpt)
|
---|
1268 | {
|
---|
1269 | switch (vpt)
|
---|
1270 | {
|
---|
1271 | case D3DCREATE_SOFTWARE_VERTEXPROCESSING: return L"Software vertex processing";
|
---|
1272 | case D3DCREATE_MIXED_VERTEXPROCESSING: return L"Mixed vertex processing";
|
---|
1273 | case D3DCREATE_HARDWARE_VERTEXPROCESSING: return L"Hardware vertex processing";
|
---|
1274 | case D3DCREATE_PUREDEVICE: return L"Pure hardware vertex processing";
|
---|
1275 | default: return L"Unknown vertex processing type";
|
---|
1276 | }
|
---|
1277 | }
|
---|
1278 |
|
---|
1279 |
|
---|
1280 | //--------------------------------------------------------------------------------------
|
---|
1281 | // Returns the string for the given present interval.
|
---|
1282 | //--------------------------------------------------------------------------------------
|
---|
1283 | WCHAR* DXUTPresentIntervalToString( UINT pi )
|
---|
1284 | {
|
---|
1285 | switch( pi )
|
---|
1286 | {
|
---|
1287 | case D3DPRESENT_INTERVAL_IMMEDIATE: return L"D3DPRESENT_INTERVAL_IMMEDIATE";
|
---|
1288 | case D3DPRESENT_INTERVAL_DEFAULT: return L"D3DPRESENT_INTERVAL_DEFAULT";
|
---|
1289 | case D3DPRESENT_INTERVAL_ONE: return L"D3DPRESENT_INTERVAL_ONE";
|
---|
1290 | case D3DPRESENT_INTERVAL_TWO: return L"D3DPRESENT_INTERVAL_TWO";
|
---|
1291 | case D3DPRESENT_INTERVAL_THREE: return L"D3DPRESENT_INTERVAL_THREE";
|
---|
1292 | case D3DPRESENT_INTERVAL_FOUR: return L"D3DPRESENT_INTERVAL_FOUR";
|
---|
1293 | default: return L"Unknown PresentInterval";
|
---|
1294 | }
|
---|
1295 | }
|
---|
1296 |
|
---|
1297 |
|
---|