2424using System ;
2525using System . Diagnostics ;
2626using System . Windows . Forms ;
27+ using static ORTS . Settings . UserSettings ;
2728
2829namespace Orts . Viewer3D . Processes
2930{
@@ -98,7 +99,7 @@ internal RenderProcess(Game game)
9899 GraphicsDeviceManager . PreferredBackBufferFormat = SurfaceFormat . Color ;
99100 GraphicsDeviceManager . PreferredDepthStencilFormat = DepthFormat . Depth24Stencil8 ;
100101 GraphicsDeviceManager . IsFullScreen = Game . Settings . FullScreen ;
101- GraphicsDeviceManager . PreferMultiSampling = true ;
102+ GraphicsDeviceManager . PreferMultiSampling = ( AntiAliasingMethod ) Game . Settings . AntiAliasing != AntiAliasingMethod . None ;
102103 GraphicsDeviceManager . HardwareModeSwitch = ! Game . Settings . FastFullScreenAltTab ;
103104 GraphicsDeviceManager . PreparingDeviceSettings += new EventHandler < PreparingDeviceSettingsEventArgs > ( GDM_PreparingDeviceSettings ) ;
104105 }
@@ -118,19 +119,38 @@ void GDM_PreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs
118119
119120 e . GraphicsDeviceInformation . GraphicsProfile = e . GraphicsDeviceInformation . Adapter . IsProfileSupported ( GraphicsProfile . HiDef ) ? GraphicsProfile . HiDef : GraphicsProfile . Reach ;
120121
121- // TODO: XNA defaults to lowest multisample anti-aliasing quality (2x), so we'll do the same here until we add a setting for it.
122- e . GraphicsDeviceInformation . PresentationParameters . MultiSampleCount = 2 ;
123-
124- if ( e . GraphicsDeviceInformation . PresentationParameters . IsFullScreen )
122+ var pp = e . GraphicsDeviceInformation . PresentationParameters ;
123+ switch ( ( AntiAliasingMethod ) Game . Settings . AntiAliasing )
124+ {
125+ case AntiAliasingMethod . None :
126+ default :
127+ break ;
128+ case AntiAliasingMethod . MSAA2x :
129+ pp . MultiSampleCount = 2 ;
130+ break ;
131+ case AntiAliasingMethod . MSAA4x :
132+ pp . MultiSampleCount = 4 ;
133+ break ;
134+ case AntiAliasingMethod . MSAA8x :
135+ pp . MultiSampleCount = 8 ;
136+ break ;
137+ case AntiAliasingMethod . MSAA16x :
138+ pp . MultiSampleCount = 16 ;
139+ break ;
140+ case AntiAliasingMethod . MSAA32x :
141+ pp . MultiSampleCount = 32 ;
142+ break ;
143+ }
144+ if ( pp . IsFullScreen )
125145 {
126146 var screen = Screen . FromControl ( GameForm ) ;
127- e . GraphicsDeviceInformation . PresentationParameters . BackBufferWidth = screen . Bounds . Width ;
128- e . GraphicsDeviceInformation . PresentationParameters . BackBufferHeight = screen . Bounds . Height ;
147+ pp . BackBufferWidth = screen . Bounds . Width ;
148+ pp . BackBufferHeight = screen . Bounds . Height ;
129149 }
130150 else
131151 {
132- e . GraphicsDeviceInformation . PresentationParameters . BackBufferWidth = GameWindowSize . X ;
133- e . GraphicsDeviceInformation . PresentationParameters . BackBufferHeight = GameWindowSize . Y ;
152+ pp . BackBufferWidth = GameWindowSize . X ;
153+ pp . BackBufferHeight = GameWindowSize . Y ;
134154 }
135155 }
136156
@@ -141,7 +161,7 @@ internal void Start()
141161 DisplaySize = new Point ( GraphicsDevice . Viewport . Width , GraphicsDevice . Viewport . Height ) ;
142162
143163 // Validate that the DirectX feature level is one we understand
144- if ( ! Enum . IsDefined ( typeof ( ORTS . Settings . UserSettings . DirectXFeature ) , "Level" + Game . Settings . DirectXFeatureLevel ) )
164+ if ( ! Enum . IsDefined ( typeof ( DirectXFeature ) , "Level" + Game . Settings . DirectXFeatureLevel ) )
145165 Game . Settings . DirectXFeatureLevel = "" ;
146166
147167 if ( Game . Settings . DirectXFeatureLevel == "" )
@@ -159,7 +179,7 @@ internal void Start()
159179 ShadowMapCount = Game . Settings . ShadowMapCount ;
160180 if ( ! Game . Settings . DynamicShadows )
161181 ShadowMapCount = 0 ;
162- else if ( ( ShadowMapCount > 1 ) && ! Game . Settings . IsDirectXFeatureLevelIncluded ( ORTS . Settings . UserSettings . DirectXFeature . Level9_3 ) )
182+ else if ( ( ShadowMapCount > 1 ) && ! Game . Settings . IsDirectXFeatureLevelIncluded ( DirectXFeature . Level9_3 ) )
163183 ShadowMapCount = 1 ;
164184 else if ( ShadowMapCount < 0 )
165185 ShadowMapCount = 0 ;
0 commit comments