private void Initialize() { // Create the form form = CreateForm(); // SwapChain description var desc = new SwapChainDescription() { BufferCount = 1, ModeDescription = new ModeDescription((int)Config.SCREEN_WIDTH, (int)Config.SCREEN_HEIGHT, new Rational(60, 1), Format.R8G8B8A8_UNorm), IsWindowed = true, OutputHandle = form.Handle, SampleDescription = new SampleDescription(1, 0), SwapEffect = SwapEffect.Discard, Usage = Usage.RenderTargetOutput }; //Create the device and swapchain try { Device1.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.BgraSupport, desc, out device, out swapChain); } catch (Exception e) { Device1.CreateWithSwapChain(DriverType.Warp, DeviceCreationFlags.BgraSupport, desc, out device, out swapChain); Console.WriteLine("Could not create Hardware drivertype, using Warp instead. \n" + e.ToString()); } // Ignore all Windows events SharpDX.DXGI.Factory factory = swapChain.GetParent <SharpDX.DXGI.Factory>(); factory.MakeWindowAssociation(form.Handle, WindowAssociationFlags.IgnoreAll); // New RenderTargetView from the backbuffer backBuffer = Texture2D.FromSwapChain <Texture2D>(swapChain, 0); backBufferView = new RenderTargetView(device, backBuffer); // Create the rendertarget for the form factory2D = new SharpDX.Direct2D1.Factory(); Surface surface = backBuffer.QueryInterface <Surface>(); renderTarget = new RenderTarget(factory2D, surface, new RenderTargetProperties(new PixelFormat(Format.Unknown, AlphaMode.Premultiplied))); renderTarget.AntialiasMode = AntialiasMode.Aliased; // Initialize the global resources used for drawing and writing. Resources.Initialize(renderTarget); runnableComponent.InitBase(); }