@@ -91,6 +91,7 @@ const int DEFAULT_RESOLUTION_WIDTH = 640;
9191const int DEFAULT_RESOLUTION_HEIGHT = 480 ;
9292const int DEFAULT_BIT_DEPTH = 32 ;
9393const int DEFAULT_TEXTURE_BIT_DEPTH = 16 ;
94+ const D3DMULTISAMPLE_TYPE DEFAULT_MSAA = D3DMULTISAMPLE_NONE;
9495
9596bool DX8Wrapper_IsWindowed = true ;
9697
@@ -114,6 +115,7 @@ int DX8Wrapper::BitDepth = DEFAULT_BIT_DEPTH;
114115int DX8Wrapper::TextureBitDepth = DEFAULT_TEXTURE_BIT_DEPTH;
115116bool DX8Wrapper::IsWindowed = false ;
116117D3DFORMAT DX8Wrapper::DisplayFormat = D3DFMT_UNKNOWN;
118+ D3DMULTISAMPLE_TYPE DX8Wrapper::MultiSampleAntiAliasing = DEFAULT_MSAA;
117119
118120D3DMATRIX DX8Wrapper::old_world;
119121D3DMATRIX DX8Wrapper::old_view;
@@ -1025,7 +1027,6 @@ bool DX8Wrapper::Set_Render_Device(int dev, int width, int height, int bits, int
10251027 _PresentParameters.BackBufferHeight = ResolutionHeight;
10261028 _PresentParameters.BackBufferCount = IsWindowed ? 1 : 2 ;
10271029
1028- _PresentParameters.MultiSampleType = D3DMULTISAMPLE_NONE;
10291030 // I changed this to discard all the time (even when full-screen) since that the most efficient. 07-16-03 MW:
10301031 _PresentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD;// IsWindowed ? D3DSWAPEFFECT_DISCARD : D3DSWAPEFFECT_FLIP; // Shouldn't this be D3DSWAPEFFECT_FLIP?
10311032 _PresentParameters.hDeviceWindow = _Hwnd;
@@ -1099,7 +1100,7 @@ bool DX8Wrapper::Set_Render_Device(int dev, int width, int height, int bits, int
10991100 }
11001101
11011102 /*
1102- ** Time to actually create the device .
1103+ ** Set default for depth stencil format if auto Z buffer failed .
11031104 */
11041105 if (_PresentParameters.AutoDepthStencilFormat ==D3DFMT_UNKNOWN) {
11051106 if (BitDepth==32 ) {
@@ -1110,6 +1111,40 @@ bool DX8Wrapper::Set_Render_Device(int dev, int width, int height, int bits, int
11101111 }
11111112 }
11121113
1114+ /*
1115+ ** Check the devices support for the requested MSAA mode then setup the multi sample type
1116+ */
1117+ if (MultiSampleAntiAliasing > D3DMULTISAMPLE_NONE) {
1118+
1119+ HRESULT hrBack = D3DInterface->CheckDeviceMultiSampleType (
1120+ CurRenderDevice,
1121+ D3DDEVTYPE_HAL,
1122+ _PresentParameters.BackBufferFormat ,
1123+ IsWindowed,
1124+ MultiSampleAntiAliasing
1125+ );
1126+
1127+ HRESULT hrDepth = D3DInterface->CheckDeviceMultiSampleType (
1128+ CurRenderDevice,
1129+ D3DDEVTYPE_HAL,
1130+ _PresentParameters.AutoDepthStencilFormat ,
1131+ IsWindowed,
1132+ MultiSampleAntiAliasing
1133+ );
1134+
1135+ if (FAILED (hrBack) || FAILED (hrDepth)) {
1136+ // IF we fail then disable MSAA entirely.
1137+ // External code needs to retrieve the configured MSAA mode after device creation
1138+ WWDEBUG_SAY ((" Requested MSAA Mode Not Supported" ));
1139+ MultiSampleAntiAliasing = D3DMULTISAMPLE_NONE;
1140+ }
1141+ }
1142+
1143+ _PresentParameters.MultiSampleType = MultiSampleAntiAliasing;
1144+
1145+ /*
1146+ ** Time to actually create the device.
1147+ */
11131148 StringClass displayFormat;
11141149 StringClass backbufferFormat;
11151150
0 commit comments