/// <summary>
        /// Initialize everything D3D in here
        ///  Leave pretty empty for now.
        /// </summary>
        protected virtual void InitD3D()
        {
            // Set up rendering mode description (width, height, frame rate, color format)
            var modeDescription = new ModeDescription(0, 0, new SlimDX.Rational(60, 1), Format.R8G8B8A8_UNorm);

            // Set up swap chain description
            var swapChainDesc = new SwapChainDescription
            {
                BufferCount       = 2,
                Usage             = Usage.RenderTargetOutput,
                OutputHandle      = Handle,
                IsWindowed        = true,
                ModeDescription   = modeDescription,
                SampleDescription = new SampleDescription(1, 0),
                Flags             = SwapChainFlags.AllowModeSwitch,
                SwapEffect        = SwapEffect.Discard
            };

            // Create our device and swap chain
            SlimDX.Direct3D11.Device.CreateWithSwapChain
            (
                DriverType.Hardware,
                DeviceCreationFlags.None,
                swapChainDesc,
                out Device,
                out SwapChain
            );

            // Obtain our device context (Immediate context)
            ImmediateContext = Device.ImmediateContext;

            // Prevent DXGI handling of alt+enter...
            using (var factory = SwapChain.GetParent <Factory>())
            {
                factory.SetWindowAssociation(Handle, WindowAssociationFlags.IgnoreAltEnter);
            }

            // Instead, handle the command ourselves
            KeyDown += (sender, e) =>
            {
                if (e.Alt && e.KeyCode == Keys.Enter)
                {
                    SwapChain.IsFullScreen = !SwapChain.IsFullScreen;
                }
            };

            // Add resize handling...
            UserResized += (sender, e) =>
            {
                OnResize(e);
            };

            // Set up viewport, render target (back buffer on swap chain), and render target view
            Viewport = new Viewport(0.0f, 0.0f, ClientSize.Width, ClientSize.Height, 0.0f, 1.0f);
            ImmediateContext.Rasterizer.SetViewports(Viewport);
            using (var resource = SlimDX.Direct3D11.Resource.FromSwapChain <Texture2D>(SwapChain, 0))
            {
                RenderTargetView = new RenderTargetView(Device, resource);
            }

            // Create the depth/stencil buffer and view
            // TODO KAM: On resize the window, do you need to resize the depth/stencil view?
            var depthBufferDesc = new Texture2DDescription
            {
                ArraySize         = 1,
                BindFlags         = BindFlags.DepthStencil,
                CpuAccessFlags    = CpuAccessFlags.None,
                Format            = Format.D32_Float,
                Height            = ClientSize.Height,
                Width             = ClientSize.Width,
                MipLevels         = 1,
                OptionFlags       = ResourceOptionFlags.None,
                SampleDescription = new SampleDescription(1, 0),
                Usage             = ResourceUsage.Default
            };

            DepthStencilBuffer = new Texture2D(Device, depthBufferDesc);

            var depthStencilViewDesc = new DepthStencilViewDescription
            {
                ArraySize       = 0,
                Format          = Format.D32_Float,
                Dimension       = DepthStencilViewDimension.Texture2D,
                MipSlice        = 0,
                Flags           = 0,
                FirstArraySlice = 0
            };

            DepthStencilView = new DepthStencilView(Device, DepthStencilBuffer, depthStencilViewDesc);

            ImmediateContext.OutputMerger.SetTargets(DepthStencilView, RenderTargetView);

            // Set up the depth/stencil state description
            var dsStateDesc = new DepthStencilStateDescription
            {
                IsDepthEnabled   = true,
                IsStencilEnabled = false,
                DepthWriteMask   = DepthWriteMask.All,
                DepthComparison  = Comparison.Less
            };

            DepthStencilState = DepthStencilState.FromDescription(Device, dsStateDesc);

            // Set depth/stencil state for the output merger
            ImmediateContext.OutputMerger.DepthStencilState = DepthStencilState;
        }