0001: //-----------------------------------------------------------------------------
0002: // File: D3DSettings.h
0003: //
0004: // Desc: Settings class and change-settings dialog class for the Direct3D 
0005: //       samples framework library.
0006: //-----------------------------------------------------------------------------
0007: #ifndef D3DSETTINGS_H
0008: #define D3DSETTINGS_H
0009: 
0010: 
0011: //-----------------------------------------------------------------------------
0012: // Name: class CD3DSettings
0013: // Desc: Current D3D settings: adapter, device, mode, formats, etc.
0014: //-----------------------------------------------------------------------------
0015: class CD3DSettings 
0016: {
0017: public:
0018:     bool IsWindowed;
0019: 
0020:     D3DAdapterInfo* pWindowed_AdapterInfo;
0021:     D3DDeviceInfo* pWindowed_DeviceInfo;
0022:     D3DDeviceCombo* pWindowed_DeviceCombo;
0023: 
0024:     D3DDISPLAYMODE Windowed_DisplayMode; // not changable by the user
0025:     D3DFORMAT Windowed_DepthStencilBufferFormat;
0026:     D3DMULTISAMPLE_TYPE Windowed_MultisampleType;
0027:     DWORD Windowed_MultisampleQuality;
0028:     VertexProcessingType Windowed_VertexProcessingType;
0029:     UINT Windowed_PresentInterval;
0030:     int Windowed_Width;
0031:     int Windowed_Height;
0032: 
0033:     D3DAdapterInfo* pFullscreen_AdapterInfo;
0034:     D3DDeviceInfo* pFullscreen_DeviceInfo;
0035:     D3DDeviceCombo* pFullscreen_DeviceCombo;
0036: 
0037:     D3DDISPLAYMODE Fullscreen_DisplayMode; // changable by the user
0038:     D3DFORMAT Fullscreen_DepthStencilBufferFormat;
0039:     D3DMULTISAMPLE_TYPE Fullscreen_MultisampleType;
0040:     DWORD Fullscreen_MultisampleQuality;
0041:     VertexProcessingType Fullscreen_VertexProcessingType;
0042:     UINT Fullscreen_PresentInterval;
0043: 
0044:     D3DAdapterInfo* PAdapterInfo() { return IsWindowed ? pWindowed_AdapterInfo : pFullscreen_AdapterInfo; }
0045:     D3DDeviceInfo* PDeviceInfo() { return IsWindowed ? pWindowed_DeviceInfo : pFullscreen_DeviceInfo; }
0046:     D3DDeviceCombo* PDeviceCombo() { return IsWindowed ? pWindowed_DeviceCombo : pFullscreen_DeviceCombo; }
0047: 
0048:     int AdapterOrdinal() { return PDeviceCombo()->AdapterOrdinal; }
0049:     D3DDEVTYPE DevType() { return PDeviceCombo()->DevType; }
0050:     D3DFORMAT BackBufferFormat() { return PDeviceCombo()->BackBufferFormat; }
0051: 
0052:     D3DDISPLAYMODE DisplayMode() { return IsWindowed ? Windowed_DisplayMode : Fullscreen_DisplayMode; }
0053:     void SetDisplayMode(D3DDISPLAYMODE value) { if (IsWindowed) Windowed_DisplayMode = value; else Fullscreen_DisplayMode = value; }
0054: 
0055:     D3DFORMAT DepthStencilBufferFormat() { return IsWindowed ? Windowed_DepthStencilBufferFormat : Fullscreen_DepthStencilBufferFormat; }
0056:     void SetDepthStencilBufferFormat(D3DFORMAT value) { if (IsWindowed) Windowed_DepthStencilBufferFormat = value; else Fullscreen_DepthStencilBufferFormat = value; }
0057: 
0058:     D3DMULTISAMPLE_TYPE MultisampleType() { return IsWindowed ? Windowed_MultisampleType : Fullscreen_MultisampleType; }
0059:     void SetMultisampleType(D3DMULTISAMPLE_TYPE value) { if (IsWindowed) Windowed_MultisampleType = value; else Fullscreen_MultisampleType = value; }
0060: 
0061:     DWORD MultisampleQuality() { return IsWindowed ? Windowed_MultisampleQuality : Fullscreen_MultisampleQuality; }
0062:     void SetMultisampleQuality(DWORD value) { if (IsWindowed) Windowed_MultisampleQuality = value; else Fullscreen_MultisampleQuality = value; }
0063: 
0064:     VertexProcessingType GetVertexProcessingType() { return IsWindowed ? Windowed_VertexProcessingType : Fullscreen_VertexProcessingType; }
0065:     void SetVertexProcessingType(VertexProcessingType value) { if (IsWindowed) Windowed_VertexProcessingType = value; else Fullscreen_VertexProcessingType = value; }
0066: 
0067:     UINT PresentInterval() { return IsWindowed ? Windowed_PresentInterval : Fullscreen_PresentInterval; }
0068:     void SetPresentInterval(UINT value) { if (IsWindowed) Windowed_PresentInterval = value; else Fullscreen_PresentInterval = value; }
0069: };
0070: 
0071: 
0072: 
0073: 
0074: //-----------------------------------------------------------------------------
0075: // Name: class CD3DSettingsDialog
0076: // Desc: Dialog box to allow the user to change the D3D settings
0077: //-----------------------------------------------------------------------------
0078: class CD3DSettingsDialog
0079: {
0080: private:
0081:     HWND m_hDlg;
0082:     CD3DEnumeration* m_pEnumeration;
0083:     CD3DSettings m_d3dSettings;
0084: 
0085: private:
0086:     // ComboBox helper functions
0087:     void ComboBoxAdd( int id, void* pData, TCHAR* pstrDesc );
0088:     void ComboBoxSelect( int id, void* pData );
0089:     void* ComboBoxSelected( int id );
0090:     bool ComboBoxSomethingSelected( int id );
0091:     UINT ComboBoxCount( int id );
0092:     void ComboBoxSelectIndex( int id, int index );
0093:     void ComboBoxClear( int id );
0094:     bool ComboBoxContainsText( int id, TCHAR* pstrText );
0095: 
0096:     void AdapterChanged( void );
0097:     void DeviceChanged( void );
0098:     void WindowedFullscreenChanged( void );
0099:     void AdapterFormatChanged( void );
0100:     void ResolutionChanged( void );
0101:     void RefreshRateChanged( void );
0102:     void BackBufferFormatChanged( void );
0103:     void DepthStencilBufferFormatChanged( void );
0104:     void MultisampleTypeChanged( void );
0105:     void MultisampleQualityChanged( void );
0106:     void VertexProcessingChanged( void );
0107:     void PresentIntervalChanged( void );
0108: 
0109: public:
0110:     CD3DSettingsDialog( CD3DEnumeration* pEnumeration, CD3DSettings* pSettings);
0111:     INT_PTR ShowDialog( HWND hwndParent );
0112:     INT_PTR DialogProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam );
0113:     void GetFinalSettings( CD3DSettings* pSettings ) { *pSettings = m_d3dSettings; }
0114: };
0115: 
0116: #endif
0117: 
0118: 
0119: 
0120: