static void Main(string[] args) { if (!File.Exists("raytracer.ini")) { try { // try to write default ini to disk using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Raytracer.raytracer.ini")) using (var f = File.OpenWrite("raytracer.ini")) { stream.CopyTo(f); } MessageBox.Show("Missing raytracer.ini. Created default ini."); } catch { MessageBox.Show("Missing raytracer.ini"); return; } } var options = IniOptions.Parse("raytracer.ini"); using (var g = new RaytracerGame(options)) { g.Run(); } }
public RaytracerGame(IniOptions options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } _options = options; new GraphicsDeviceManager(this) { PreferredBackBufferWidth = options.Width, PreferredBackBufferHeight = options.Height }; _raytracer = _options.Multithreaded ? new MultiThreadedRaytracer() : new Raytracer(); if (options.Width % options.RealtimeRasterLevel != 0) { throw new NotSupportedException("Width must be divisible by RealtimeRasterSize"); } if (options.Height % options.RealtimeRasterLevel != 0) { throw new NotSupportedException("Height must be divisible by RealtimeRasterSize"); } if (options.Width % options.BackgroundRasterLevel != 0) { throw new NotSupportedException("Width must be divisible by RealtimeRasterSize"); } if (options.Height % options.BackgroundRasterLevel != 0) { throw new NotSupportedException("Height must be divisible by RealtimeRasterSize"); } }