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

游戏

开发平台:

Visual C++

  1. //-----------------------------------------------------------------------------
  2. // File: D3DSettings.h
  3. //
  4. // Desc: Settings class and change-settings dialog class for the Direct3D 
  5. //       samples framework library.
  6. //
  7. // Copyright (c) Microsoft Corporation. All rights reserved.
  8. //-----------------------------------------------------------------------------
  9. #ifndef D3DSETTINGS_H
  10. #define D3DSETTINGS_H
  11. //-----------------------------------------------------------------------------
  12. // Name: class CD3DSettings
  13. // Desc: Current D3D settings: adapter, device, mode, formats, etc.
  14. //-----------------------------------------------------------------------------
  15. class CD3DSettings 
  16. {
  17. public:
  18.     bool IsWindowed;
  19.     D3DAdapterInfo* pWindowed_AdapterInfo;
  20.     D3DDeviceInfo* pWindowed_DeviceInfo;
  21.     D3DDeviceCombo* pWindowed_DeviceCombo;
  22.     D3DDISPLAYMODE Windowed_DisplayMode; // not changable by the user
  23.     D3DFORMAT Windowed_DepthStencilBufferFormat;
  24.     D3DMULTISAMPLE_TYPE Windowed_MultisampleType;
  25.     DWORD Windowed_MultisampleQuality;
  26.     VertexProcessingType Windowed_VertexProcessingType;
  27.     UINT Windowed_PresentInterval;
  28.     bool bDeviceClip;
  29.     int Windowed_Width;
  30.     int Windowed_Height;
  31.     D3DAdapterInfo* pFullscreen_AdapterInfo;
  32.     D3DDeviceInfo* pFullscreen_DeviceInfo;
  33.     D3DDeviceCombo* pFullscreen_DeviceCombo;
  34.     D3DDISPLAYMODE Fullscreen_DisplayMode; // changable by the user
  35.     D3DFORMAT Fullscreen_DepthStencilBufferFormat;
  36.     D3DMULTISAMPLE_TYPE Fullscreen_MultisampleType;
  37.     DWORD Fullscreen_MultisampleQuality;
  38.     VertexProcessingType Fullscreen_VertexProcessingType;
  39.     UINT Fullscreen_PresentInterval;
  40.     D3DAdapterInfo* PAdapterInfo() { return IsWindowed ? pWindowed_AdapterInfo : pFullscreen_AdapterInfo; }
  41.     D3DDeviceInfo* PDeviceInfo() { return IsWindowed ? pWindowed_DeviceInfo : pFullscreen_DeviceInfo; }
  42.     D3DDeviceCombo* PDeviceCombo() { return IsWindowed ? pWindowed_DeviceCombo : pFullscreen_DeviceCombo; }
  43.     int AdapterOrdinal() { return PDeviceCombo()->AdapterOrdinal; }
  44.     D3DDEVTYPE DevType() { return PDeviceCombo()->DevType; }
  45.     D3DFORMAT BackBufferFormat() { return PDeviceCombo()->BackBufferFormat; }
  46.     D3DDISPLAYMODE DisplayMode() { return IsWindowed ? Windowed_DisplayMode : Fullscreen_DisplayMode; }
  47.     void SetDisplayMode(D3DDISPLAYMODE value) { if (IsWindowed) Windowed_DisplayMode = value; else Fullscreen_DisplayMode = value; }
  48.     D3DFORMAT DepthStencilBufferFormat() { return IsWindowed ? Windowed_DepthStencilBufferFormat : Fullscreen_DepthStencilBufferFormat; }
  49.     void SetDepthStencilBufferFormat(D3DFORMAT value) { if (IsWindowed) Windowed_DepthStencilBufferFormat = value; else Fullscreen_DepthStencilBufferFormat = value; }
  50.     D3DMULTISAMPLE_TYPE MultisampleType() { return IsWindowed ? Windowed_MultisampleType : Fullscreen_MultisampleType; }
  51.     void SetMultisampleType(D3DMULTISAMPLE_TYPE value) { if (IsWindowed) Windowed_MultisampleType = value; else Fullscreen_MultisampleType = value; }
  52.     DWORD MultisampleQuality() { return IsWindowed ? Windowed_MultisampleQuality : Fullscreen_MultisampleQuality; }
  53.     void SetMultisampleQuality(DWORD value) { if (IsWindowed) Windowed_MultisampleQuality = value; else Fullscreen_MultisampleQuality = value; }
  54.     VertexProcessingType GetVertexProcessingType() { return IsWindowed ? Windowed_VertexProcessingType : Fullscreen_VertexProcessingType; }
  55.     void SetVertexProcessingType(VertexProcessingType value) { if (IsWindowed) Windowed_VertexProcessingType = value; else Fullscreen_VertexProcessingType = value; }
  56.     UINT PresentInterval() { return IsWindowed ? Windowed_PresentInterval : Fullscreen_PresentInterval; }
  57.     void SetPresentInterval(UINT value) { if (IsWindowed) Windowed_PresentInterval = value; else Fullscreen_PresentInterval = value; }
  58.     bool DeviceClip() { return bDeviceClip; }
  59.     void SetDeviceClip( bool bClip ) { bDeviceClip = bClip; }
  60. };
  61. //-----------------------------------------------------------------------------
  62. // Name: class CD3DSettingsDialog
  63. // Desc: Dialog box to allow the user to change the D3D settings
  64. //-----------------------------------------------------------------------------
  65. class CD3DSettingsDialog
  66. {
  67. private:
  68.     HWND m_hDlg;
  69.     CD3DEnumeration* m_pEnumeration;
  70.     CD3DSettings m_d3dSettings;
  71. private:
  72.     // ComboBox helper functions
  73.     void ComboBoxAdd( int id, void* pData, LPCTSTR pstrDesc );
  74.     void ComboBoxSelect( int id, void* pData );
  75.     void* ComboBoxSelected( int id );
  76.     bool ComboBoxSomethingSelected( int id );
  77.     UINT ComboBoxCount( int id );
  78.     void ComboBoxSelectIndex( int id, int index );
  79.     void ComboBoxClear( int id );
  80.     bool ComboBoxContainsText( int id, LPCTSTR pstrText );
  81.     void AdapterChanged( void );
  82.     void DeviceChanged( void );
  83.     void WindowedFullscreenChanged( void );
  84.     void AdapterFormatChanged( void );
  85.     void ResolutionChanged( void );
  86.     void RefreshRateChanged( void );
  87.     void BackBufferFormatChanged( void );
  88.     void DepthStencilBufferFormatChanged( void );
  89.     void MultisampleTypeChanged( void );
  90.     void MultisampleQualityChanged( void );
  91.     void VertexProcessingChanged( void );
  92.     void PresentIntervalChanged( void );
  93.     void DeviceClipChanged( void );
  94. public:
  95.     CD3DSettingsDialog( CD3DEnumeration* pEnumeration, CD3DSettings* pSettings);
  96.     INT_PTR ShowDialog( HWND hwndParent );
  97.     INT_PTR DialogProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam );
  98.     void GetFinalSettings( CD3DSettings* pSettings ) { *pSettings = m_d3dSettings; }
  99. };
  100. #endif