public Renderer(int Width, int Height, IntPtr? OutputHandle)
 {
     if (Width < 1)
         Width = 1;
     if (Height < 1)
         Height = 1;
     bufferWidth = Width;
     bufferHeight = Height;
     deviceUsers++;
     if (device == null)
         device = new Device(DriverType.Hardware, DeviceCreationFlags.Debug | DeviceCreationFlags.BgraSupport, FeatureLevel.Level_11_0);
     if (OutputHandle.HasValue)
     {
         SwapChainDescription swapChainDesc = new SwapChainDescription()
         {
             BufferCount = 1,
             ModeDescription = new ModeDescription(BufferWidth, BufferHeight, new Rational(120, 1), Format.R8G8B8A8_UNorm),
             IsWindowed = true,
             OutputHandle = OutputHandle.Value,
             SampleDescription = BufferSampleDescription,
             SwapEffect = SwapEffect.Discard,
             Usage = Usage.RenderTargetOutput,
             Flags = SwapChainFlags.AllowModeSwitch,
         };
         swapChain = new SwapChain(device.Factory, Device, swapChainDesc);
         using (var factory = swapChain.GetParent<Factory>())
             factory.SetWindowAssociation(OutputHandle.Value, WindowAssociationFlags.IgnoreAltEnter);
     }
     LightingSystem = new ForwardLighting(this);
     SetupRenderTargets();
     LightingSystem.Initialize();
 }
 void SetLightingSystem(string name, LightingSystem newLS)
 {
     if (info.Text != name)
     {
         List<Light> ls = Viewport.Renderer.LightingSystem.Lights;
         Storyboard st = (this.FindResource("infoAnimation") as Storyboard);
         st.Completed += MainWindow_Completed;
         Viewport.Renderer.LightingSystem.Dispose();
         Viewport.Renderer.LightingSystem = newLS;
         Viewport.Renderer.LightingSystem.Initialize();
         //GenerateLights((int)lightSlider.Value);
         Viewport.Renderer.LightingSystem.Lights = ls;
         info.Text = name;
         st.Begin();
     }
 }