📄 dxutsettingsdlg.cpp
字号:
g_DeviceSettings.d3d9.pp.BackBufferFormat = D3DFMT_UNKNOWN;
g_DeviceSettings.d3d9.pp.FullScreen_RefreshRateInHz = 0;
}
else
{
// DXUTSETTINGSDLG_BACK_BUFFER_FORMAT
pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_BACK_BUFFER_FORMAT );
g_DeviceSettings.d3d9.pp.BackBufferFormat = (D3DFORMAT) PtrToUlong( pComboBox->GetSelectedData() );
// DXUTSETTINGSDLG_RESOLUTION
pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_RESOLUTION );
DWORD dwResolution = PtrToUlong( pComboBox->GetSelectedData() );
g_DeviceSettings.d3d9.pp.BackBufferWidth = HIWORD( dwResolution );
g_DeviceSettings.d3d9.pp.BackBufferHeight = LOWORD( dwResolution );
// DXUTSETTINGSDLG_REFRESH_RATE
pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_REFRESH_RATE );
g_DeviceSettings.d3d9.pp.FullScreen_RefreshRateInHz = PtrToUlong( pComboBox->GetSelectedData() );
}
// DXUTSETTINGSDLG_DEPTH_STENCIL
pComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_DEPTH_STENCIL );
g_DeviceSettings.d3d9.pp.AutoDepthStencilFormat = (D3DFORMAT) PtrToUlong( pComboBox->GetSelectedData() );
return S_OK;
}
//-------------------------------------------------------------------------------------
CD3D9EnumAdapterInfo* CD3DSettingsDlg::GetCurrentAdapterInfo()
{
CD3D9Enumeration* pD3DEnum = DXUTGetD3D9Enumeration();
return pD3DEnum->GetAdapterInfo( g_DeviceSettings.d3d9.AdapterOrdinal );
}
//-------------------------------------------------------------------------------------
CD3D9EnumDeviceInfo* CD3DSettingsDlg::GetCurrentDeviceInfo()
{
CD3D9Enumeration* pD3DEnum = DXUTGetD3D9Enumeration();
return pD3DEnum->GetDeviceInfo( g_DeviceSettings.d3d9.AdapterOrdinal,
g_DeviceSettings.d3d9.DeviceType );
}
//-------------------------------------------------------------------------------------
CD3D10EnumAdapterInfo* CD3DSettingsDlg::GetCurrentD3D10AdapterInfo()
{
CD3D10Enumeration* pD3DEnum = DXUTGetD3D10Enumeration();
return pD3DEnum->GetAdapterInfo( g_DeviceSettings.d3d10.AdapterOrdinal );
}
//-------------------------------------------------------------------------------------
CD3D10EnumDeviceInfo* CD3DSettingsDlg::GetCurrentD3D10DeviceInfo()
{
CD3D10Enumeration* pD3DEnum = DXUTGetD3D10Enumeration();
return pD3DEnum->GetDeviceInfo( g_DeviceSettings.d3d10.AdapterOrdinal,
g_DeviceSettings.d3d10.DriverType );
}
//-------------------------------------------------------------------------------------
CD3D10EnumOutputInfo* CD3DSettingsDlg::GetCurrentD3D10OutputInfo()
{
CD3D10Enumeration* pD3DEnum = DXUTGetD3D10Enumeration();
return pD3DEnum->GetOutputInfo( g_DeviceSettings.d3d10.AdapterOrdinal,
g_DeviceSettings.d3d10.Output );
}
//-------------------------------------------------------------------------------------
CD3D9EnumDeviceSettingsCombo* CD3DSettingsDlg::GetCurrentDeviceSettingsCombo()
{
CD3D9Enumeration* pD3DEnum = DXUTGetD3D9Enumeration();
return pD3DEnum->GetDeviceSettingsCombo( g_DeviceSettings.d3d9.AdapterOrdinal,
g_DeviceSettings.d3d9.DeviceType,
g_DeviceSettings.d3d9.AdapterFormat,
g_DeviceSettings.d3d9.pp.BackBufferFormat,
(g_DeviceSettings.d3d9.pp.Windowed == TRUE) );
}
//-------------------------------------------------------------------------------------
CD3D10EnumDeviceSettingsCombo* CD3DSettingsDlg::GetCurrentD3D10DeviceSettingsCombo()
{
CD3D10Enumeration* pD3DEnum = DXUTGetD3D10Enumeration();
return pD3DEnum->GetDeviceSettingsCombo( g_DeviceSettings.d3d10.AdapterOrdinal,
g_DeviceSettings.d3d10.DriverType,
g_DeviceSettings.d3d10.Output,
g_DeviceSettings.d3d10.sd.BufferDesc.Format,
(g_DeviceSettings.d3d10.sd.Windowed == TRUE) );
}
//-------------------------------------------------------------------------------------
HRESULT CD3DSettingsDlg::OnAPIVersionChanged( bool bRefresh )
{
HRESULT hr;
// Store the API version
g_DeviceSettings.ver = GetSelectedAPIVersion();
// Show/hide appropriate dialog controls based on version.
ShowControlSet( g_DeviceSettings.ver );
switch( g_DeviceSettings.ver )
{
case DXUT_D3D9_DEVICE:
{
if( !bRefresh )
{
// Obtain a set of valid D3D9 device settings.
UINT CreateFlags = g_DeviceSettings.d3d10.CreateFlags;
ZeroMemory( &g_DeviceSettings, sizeof(g_DeviceSettings) );
g_DeviceSettings.d3d10.CreateFlags = CreateFlags;
g_DeviceSettings.ver = DXUT_D3D9_DEVICE;
// We want a specific API version, so set up match option to preserve it.
DXUTMatchOptions MatchOptions;
ZeroMemory( &MatchOptions, sizeof( MatchOptions ) );
MatchOptions.eAPIVersion = DXUTMT_PRESERVE_INPUT;
DXUTFindValidDeviceSettings( &g_DeviceSettings, &g_DeviceSettings, &MatchOptions );
}
CD3D9Enumeration* pD3DEnum = DXUTGetD3D9Enumeration();
CGrowableArray<CD3D9EnumAdapterInfo*> *pAdapterInfoList = pD3DEnum->GetAdapterInfoList();
CDXUTComboBox* pAdapterComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_ADAPTER );
pAdapterComboBox->RemoveAllItems();
for( int iAdapter = 0; iAdapter < pAdapterInfoList->GetSize(); ++iAdapter )
{
CD3D9EnumAdapterInfo* pAdapterInfo = pAdapterInfoList->GetAt(iAdapter);
AddAdapter( pAdapterInfo->szUniqueDescription, pAdapterInfo->AdapterOrdinal );
}
pAdapterComboBox->SetSelectedByData( ULongToPtr(g_DeviceSettings.d3d9.AdapterOrdinal) );
hr = OnAdapterChanged();
if( FAILED(hr) )
return hr;
break;
}
case DXUT_D3D10_DEVICE:
{
if( !bRefresh )
{
// Obtain a set of valid D3D10 device settings.
UINT CreateFlags = g_DeviceSettings.d3d10.CreateFlags;
ZeroMemory( &g_DeviceSettings, sizeof(g_DeviceSettings) );
g_DeviceSettings.d3d10.CreateFlags = CreateFlags;
g_DeviceSettings.ver = DXUT_D3D10_DEVICE;
// We want a specific API version, so set up match option to preserve it.
DXUTMatchOptions MatchOptions;
ZeroMemory( &MatchOptions, sizeof( MatchOptions ) );
MatchOptions.eAPIVersion = DXUTMT_PRESERVE_INPUT;
DXUTFindValidDeviceSettings( &g_DeviceSettings, &g_DeviceSettings, &MatchOptions );
}
CD3D10Enumeration* pD3DEnum = DXUTGetD3D10Enumeration();
CGrowableArray<CD3D10EnumAdapterInfo*> *pAdapterInfoList = pD3DEnum->GetAdapterInfoList();
CDXUTComboBox* pAdapterComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_ADAPTER );
pAdapterComboBox->RemoveAllItems();
for( int iAdapter = 0; iAdapter < pAdapterInfoList->GetSize(); ++iAdapter )
{
CD3D10EnumAdapterInfo* pAdapterInfo = pAdapterInfoList->GetAt(iAdapter);
AddAdapter( pAdapterInfo->szUniqueDescription, pAdapterInfo->AdapterOrdinal );
}
pAdapterComboBox->SetSelectedByData( ULongToPtr(g_DeviceSettings.d3d10.AdapterOrdinal) );
CDXUTCheckBox* pCheckBox = m_Dialog.GetCheckBox( DXUTSETTINGSDLG_D3D10_DEBUG_DEVICE );
pCheckBox->SetChecked( 0 != (g_DeviceSettings.d3d10.CreateFlags & D3D10_CREATE_DEVICE_DEBUG) );
hr = OnAdapterChanged();
if( FAILED(hr) )
return hr;
break;
}
}
return S_OK;
}
//-------------------------------------------------------------------------------------
HRESULT CD3DSettingsDlg::OnAdapterChanged()
{
HRESULT hr = S_OK;
switch( g_DeviceSettings.ver )
{
case DXUT_D3D9_DEVICE:
{
// Store the adapter index
g_DeviceSettings.d3d9.AdapterOrdinal = GetSelectedAdapter();
// DXUTSETTINGSDLG_DEVICE_TYPE
CDXUTComboBox* pDeviceTypeComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_DEVICE_TYPE );
pDeviceTypeComboBox->RemoveAllItems();
CD3D9EnumAdapterInfo* pAdapterInfo = GetCurrentAdapterInfo();
if( pAdapterInfo == NULL )
return E_FAIL;
for( int iDeviceInfo=0; iDeviceInfo < pAdapterInfo->deviceInfoList.GetSize(); iDeviceInfo++ )
{
CD3D9EnumDeviceInfo* pDeviceInfo = pAdapterInfo->deviceInfoList.GetAt(iDeviceInfo);
AddDeviceType( pDeviceInfo->DeviceType );
}
pDeviceTypeComboBox->SetSelectedByData( ULongToPtr(g_DeviceSettings.d3d9.DeviceType) );
hr = OnDeviceTypeChanged();
if( FAILED(hr) )
return hr;
break;
}
case DXUT_D3D10_DEVICE:
{
// Store the adapter index
g_DeviceSettings.d3d10.AdapterOrdinal = GetSelectedAdapter();
// DXUTSETTINGSDLG_DEVICE_TYPE
CDXUTComboBox* pDeviceTypeComboBox = m_Dialog.GetComboBox( DXUTSETTINGSDLG_DEVICE_TYPE );
pDeviceTypeComboBox->RemoveAllItems();
CD3D10EnumAdapterInfo* pAdapterInfo = GetCurrentD3D10AdapterInfo();
if( pAdapterInfo == NULL )
return E_FAIL;
for( int iDeviceInfo=0; iDeviceInfo < pAdapterInfo->deviceInfoList.GetSize(); iDeviceInfo++ )
{
CD3D10EnumDeviceInfo* pDeviceInfo = pAdapterInfo->deviceInfoList.GetAt(iDeviceInfo);
AddD3D10DeviceType( pDeviceInfo->DeviceType );
}
pDeviceTypeComboBox->SetSelectedByData( ULongToPtr(g_DeviceSettings.d3d10.DriverType) );
hr = OnDeviceTypeChanged();
if( FAILED(hr) )
return hr;
break;
}
}
return S_OK;
}
//-------------------------------------------------------------------------------------
HRESULT CD3DSettingsDlg::OnDeviceTypeChanged()
{
HRESULT hr = S_OK;
switch( g_DeviceSettings.ver )
{
case DXUT_D3D9_DEVICE:
{
g_DeviceSettings.d3d9.DeviceType = GetSelectedDeviceType();
// Update windowed/full screen radio buttons
bool bHasWindowedDeviceCombo = false;
bool bHasFullScreenDeviceCombo = false;
CD3D9EnumDeviceInfo* pDeviceInfo = GetCurrentDeviceInfo();
if( pDeviceInfo == NULL )
return E_FAIL;
for( int idc = 0; idc < pDeviceInfo->deviceSettingsComboList.GetSize(); idc++ )
{
CD3D9EnumDeviceSettingsCombo* pDeviceSettingsCombo = pDeviceInfo->deviceSettingsComboList.GetAt( idc );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -