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 / d3dsettings.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-11-12  |  5.3 KB  |  120 lines

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