Ejemplo n.º 1
0
 static IntPtr GetSharedHandle(SlimDX.Direct3D10.Texture2D texture)
 {
     using (var resource = new SlimDX.DXGI.Resource(texture))
     {
         return(resource.SharedHandle);
     }
 }
Ejemplo n.º 2
0
        public override void ToggleFullScreen(IntPtr handle)
        {
            //if (LostDevice != null)
            //    LostDevice();

            factory.SetWindowAssociation(handle, SlimDX.DXGI.WindowAssociationFlags.IgnoreAll);


            SwapChain.Dispose();
            backBuffer.Dispose();
            RenderView.Dispose();

            SwapChain = new SlimDX.DXGI.SwapChain(factory, Device10, new SlimDX.DXGI.SwapChainDescription
            {
                BufferCount       = 1,
                ModeDescription   = new SlimDX.DXGI.ModeDescription(View.ClientSize.Width, View.ClientSize.Height, new Rational(60, 1), SlimDX.DXGI.Format.R8G8B8A8_UNorm),
                IsWindowed        = false,
                OutputHandle      = handle,
                SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0),
                SwapEffect        = SlimDX.DXGI.SwapEffect.Discard,
                Usage             = SlimDX.DXGI.Usage.RenderTargetOutput,
                Flags             = SlimDX.DXGI.SwapChainFlags.AllowModeSwitch
            });
            backBuffer = SlimDX.Direct3D10.Texture2D.FromSwapChain <SlimDX.Direct3D10.Texture2D>(SwapChain, 0);
            RenderView = new SlimDX.Direct3D10.RenderTargetView(Device10, backBuffer);

            //Create(handle);

            //SwapChain.SetFullScreenState(true, null);

            //if (ResetDevice != null)
            //    ResetDevice();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a default D3D11 Texture with forced Shared-Flag
        /// </summary>
        /// <param name="device"></param>
        /// <param name="description"></param>
        /// <param name="D3D10Dev"> </param>
        /// <param name="D2DFactory"> </param>
        public SharedTexture(D2DInteropHandler handler, Texture2DDescription description)
        {
            As11Tex = new Texture2D(handler.D3DDevice11, new Texture2DDescription()
                {
                    ArraySize = description.ArraySize,
                    BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
                    CpuAccessFlags = description.CpuAccessFlags,
                    Format = description.Format,
                    Height = description.Height,
                    MipLevels = description.MipLevels,
                    OptionFlags = ResourceOptionFlags.KeyedMutex,
                    SampleDescription = description.SampleDescription,
                    Usage = description.Usage,
                    Width = description.Width
                });

            Mutex11 = new KeyedMutex(As11Tex);
            AsResource = new SlimDX.DXGI.Resource(As11Tex);

            As10Tex = handler.D3DDevice10.OpenSharedResource<SlimDX.Direct3D10.Texture2D>(AsResource.SharedHandle);
            Mutex10 = new KeyedMutex(As10Tex);
            AsSurface = As10Tex.AsSurface();
            As2DTarget = SlimDX.Direct2D.RenderTarget.FromDXGI(handler.D2DFactory, AsSurface, new RenderTargetProperties()
                                                                                                            {
                                                                                                                MinimumFeatureLevel = FeatureLevel.Direct3D10,
                                                                                                                Usage = RenderTargetUsage.None,
                                                                                                                Type = RenderTargetType.Hardware,
                                                                                                                PixelFormat = new PixelFormat(Format.Unknown, AlphaMode.Premultiplied)
                                                                                                            });
        }
Ejemplo n.º 4
0
 public static T[,] MapReadTexture <T>(SlimDX.Direct3D10.Texture2D texture, int level) where T : struct
 {
     var d    = texture.Map(level, SlimDX.Direct3D10.MapMode.Read, SlimDX.Direct3D10.MapFlags.None);
     var sd   = texture.Description;
     var data = ReadTexture <T>(d, sd.Width, sd.Height);
     texture.Unmap(level);
     return(data);
 }
Ejemplo n.º 5
0
        IntPtr GetSharedHandle(SlimDX.Direct3D10.Texture2D Texture)
        {
            SlimDX.DXGI.Resource resource = new SlimDX.DXGI.Resource(Texture);
            IntPtr result = resource.SharedHandle;

            resource.Dispose();

            return(result);
        }
Ejemplo n.º 6
0
        private void BeginRenderingScene()
        {
            if (_dxImageContainer.IsFrontBufferAvailable)
            {
                SlimDX.Direct3D10.Texture2D texture = _dxScene.SharedTexture;
                _dxImageContainer.SetBackBufferSlimDX(texture);

                CompositionTarget.Rendering += OnRendering;

                _timer.Start();
            }
        }
Ejemplo n.º 7
0
        void Window_Loaded(object sender, RoutedEventArgs e)
        {
            D3DImageContainer = new D3DImageSlimDX();
            D3DImageContainer.IsFrontBufferAvailableChanged += OnIsFrontBufferAvailableChanged;

            SlimDXImage.Source = D3DImageContainer;

            D3DScene = new Scene();
            SlimDX.Direct3D10.Texture2D Texture = D3DScene.SharedTexture;

            D3DImageContainer.SetBackBufferSlimDX(Texture);
            BeginRenderingScene();
        }
Ejemplo n.º 8
0
        void BeginRenderingScene()
        {
            if (D3DImageContainer.IsFrontBufferAvailable)
            {
                foreach (var item in SlimDX.ObjectTable.Objects)
                {
                }

                SlimDX.Direct3D10.Texture2D Texture = D3DScene.SharedTexture;
                D3DImageContainer.SetBackBufferSlimDX(Texture);
                CompositionTarget.Rendering += OnRendering;

                Timer.Start();
            }
        }
Ejemplo n.º 9
0
        protected void BeginRenderingScene()
        {
            if (_d3DScene == null)
            {
                return;
            }

            if (D3DImageContainer.IsFrontBufferAvailable)
            {
                SlimDX.Direct3D10.Texture2D Texture = _d3DScene.SharedTexture;
                D3DImageContainer.SetBackBufferSlimDX(Texture);
                CompositionTarget.Rendering += OnRendering;
                Timer.Start();
            }
        }
Ejemplo n.º 10
0
        // SlimDX.Direct3D10
        private SlimDX.Direct3D10.ShaderResourceView GetTexture(SlimDX.Direct3D10.Device device, int width, int height, SlimDX.Color4 color)
        {
            //create the texture
            SlimDX.Direct3D10.Texture2D            texture = null;
            SlimDX.Direct3D10.Texture2DDescription desc2   = new SlimDX.Direct3D10.Texture2DDescription();
            desc2.SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0);
            desc2.Width             = width;
            desc2.Height            = height;
            desc2.MipLevels         = 1;
            desc2.ArraySize         = 1;
            desc2.Format            = SlimDX.DXGI.Format.R8G8B8A8_UNorm;
            desc2.Usage             = SlimDX.Direct3D10.ResourceUsage.Dynamic;
            desc2.BindFlags         = SlimDX.Direct3D10.BindFlags.ShaderResource;
            desc2.CpuAccessFlags    = SlimDX.Direct3D10.CpuAccessFlags.Write;
            texture = new SlimDX.Direct3D10.Texture2D(device, desc2);


            // fill the texture with rgba values
            SlimDX.DataRectangle rect = texture.Map(0, SlimDX.Direct3D10.MapMode.WriteDiscard, SlimDX.Direct3D10.MapFlags.None);
            if (rect.Data.CanWrite)
            {
                for (int row = 0; row < texture.Description.Height; row++)
                {
                    int rowStart = row * rect.Pitch;
                    rect.Data.Seek(rowStart, System.IO.SeekOrigin.Begin);
                    for (int col = 0; col < texture.Description.Width; col++)
                    {
                        rect.Data.WriteByte((byte)color.Red);
                        rect.Data.WriteByte((byte)color.Green);
                        rect.Data.WriteByte((byte)color.Blue);
                        rect.Data.WriteByte((byte)color.Alpha);
                    }
                }
            }
            texture.Unmap(0);

            // create shader resource that is what the renderer needs
            SlimDX.Direct3D10.ShaderResourceViewDescription desc = new SlimDX.Direct3D10.ShaderResourceViewDescription();
            desc.Format          = texture.Description.Format;
            desc.Dimension       = SlimDX.Direct3D10.ShaderResourceViewDimension.Texture2D;
            desc.MostDetailedMip = 0;
            desc.MipLevels       = 1;


            SlimDX.Direct3D10.ShaderResourceView srv = new SlimDX.Direct3D10.ShaderResourceView(device, texture, desc);

            return(srv);
        }
Ejemplo n.º 11
0
        public void SetBackBufferSlimDX(SlimDX.Direct3D10.Texture2D Texture)
        {
            if (SharedTexture != null)
            {
                SharedTexture.Dispose();
                SharedTexture = null;
            }

            if (Texture == null)
            {
                if (SharedTexture != null)
                {
                    SharedTexture = null;
                    Lock();
                    SetBackBuffer(D3DResourceType.IDirect3DSurface9, IntPtr.Zero);
                    Unlock();
                }
            }
            else if (IsShareable(Texture))
            {
                Format format = TranslateFormat(Texture);
                if (format == Format.Unknown)
                {
                    throw new ArgumentException("Texture format is not compatible with OpenSharedResource");
                }

                IntPtr Handle = GetSharedHandle(Texture);
                if (Handle == IntPtr.Zero)
                {
                    throw new ArgumentNullException("Handle");
                }

                SharedTexture = new Texture(D3DDevice, Texture.Description.Width, Texture.Description.Height, 1,
                                            Usage.RenderTarget, format, Pool.Default, ref Handle);

                using (Surface Surface = SharedTexture.GetSurfaceLevel(0))
                {
                    Lock();
                    SetBackBuffer(D3DResourceType.IDirect3DSurface9, Surface.ComPointer);
                    Unlock();
                }
            }
            else
            {
                throw new ArgumentException("Texture must be created with ResourceOptionFlags.Shared");
            }
        }
Ejemplo n.º 12
0
        Format TranslateFormat(SlimDX.Direct3D10.Texture2D Texture)
        {
            switch (Texture.Description.Format)
            {
            case SlimDX.DXGI.Format.R10G10B10A2_UNorm:
                return(SlimDX.Direct3D9.Format.A2B10G10R10);

            case SlimDX.DXGI.Format.R16G16B16A16_Float:
                return(SlimDX.Direct3D9.Format.A16B16G16R16F);

            case SlimDX.DXGI.Format.B8G8R8A8_UNorm:
                return(SlimDX.Direct3D9.Format.A8R8G8B8);

            default:
                return(SlimDX.Direct3D9.Format.Unknown);
            }
        }
Ejemplo n.º 13
0
        public static void WriteTexture <T>(SlimDX.Direct3D10.Texture2D texture, T[,] data, int TSize)
            where T : struct
        {
            var dr    = texture.Map(0, SlimDX.Direct3D10.MapMode.WriteDiscard, SlimDX.Direct3D10.MapFlags.None);
            int width = data.GetLength(1);

            if (dr.Pitch == data.GetLength(1) * TSize)
            {
                dr.Data.WriteRange(Common.Utils.Flatten(data));
            }
            else
            {
                for (int y = 0; y < texture.Description.Height; y++)
                {
                    dr.Data.WriteRange(Common.Utils.GetRow(data, y));
                    dr.Data.Seek(dr.Pitch - width * TSize, System.IO.SeekOrigin.Current);
                }
            }
            texture.Unmap(0);
        }
Ejemplo n.º 14
0
        public static void CopyWriteTexture <T>(SlimDX.Direct3D10.Texture2D texture, T[,] data, int TSize)
            where T : struct
        {
            var dr   = ToDataRectangle(data, TSize);
            var copy = new SlimDX.Direct3D10.Texture2D(texture.Device, new SlimDX.Direct3D10.Texture2DDescription
            {
                ArraySize         = texture.Description.ArraySize,
                BindFlags         = SlimDX.Direct3D10.BindFlags.None,
                CpuAccessFlags    = SlimDX.Direct3D10.CpuAccessFlags.None,
                Format            = texture.Description.Format,
                Width             = texture.Description.Width,
                Height            = texture.Description.Height,
                MipLevels         = texture.Description.MipLevels,
                Usage             = SlimDX.Direct3D10.ResourceUsage.Default,
                SampleDescription = texture.Description.SampleDescription,
                OptionFlags       = SlimDX.Direct3D10.ResourceOptionFlags.None
            }, dr);

            texture.Device.CopyResource(copy, texture);
            copy.Dispose();
        }
Ejemplo n.º 15
0
 public static T[,] CopyReadTexture <T>(SlimDX.Direct3D10.Texture2D texture, int level) where T : struct
 {
     var copy = new SlimDX.Direct3D10.Texture2D(texture.Device, new SlimDX.Direct3D10.Texture2DDescription
     {
         ArraySize         = texture.Description.ArraySize,
         BindFlags         = SlimDX.Direct3D10.BindFlags.None,
         CpuAccessFlags    = SlimDX.Direct3D10.CpuAccessFlags.Read,
         Format            = texture.Description.Format,
         Width             = texture.Description.Width,
         Height            = texture.Description.Height,
         MipLevels         = texture.Description.MipLevels,
         Usage             = SlimDX.Direct3D10.ResourceUsage.Staging,
         SampleDescription = texture.Description.SampleDescription,
         OptionFlags       = SlimDX.Direct3D10.ResourceOptionFlags.None
     });
     texture.Device.CopyResource(texture, copy);
     var d    = copy.Map(level, SlimDX.Direct3D10.MapMode.Read, SlimDX.Direct3D10.MapFlags.None);
     var sd   = copy.Description;
     var data = ReadTexture <T>(d, sd.Width, sd.Height);
     copy.Unmap(level);
     copy.Dispose();
     return(data);
 }
Ejemplo n.º 16
0
        private void OnRendering(object sender, EventArgs e)
        {
            var re   = (RenderingEventArgs)e;
            var time = re.RenderingTime;

            _dxScene.Wireframe = renderProps.Wireframe;

            SlimDX.Direct3D10.Texture2D lastTexture = _dxScene.SharedTexture;

            _dxScene.Render((float)time.TotalSeconds,
                            (int)helixView.ActualWidth, (int)helixView.ActualHeight);

            // output buffer could change because of size change
            if (lastTexture != _dxScene.SharedTexture)
            {
                _dxImageContainer.SetBackBufferSlimDX(_dxScene.SharedTexture);
            }

            _dxImageContainer.InvalidateD3DImage();

            _frameCounter.AddFrame();
            textFrameRate.Text = _frameCounter.FramesPerSecond.ToString("f1");
        }
Ejemplo n.º 17
0
        public override void Create(IntPtr handle)
        {
            var desc = new SlimDX.DXGI.SwapChainDescription()
            {
                BufferCount     = 1,
                ModeDescription = new SlimDX.DXGI.ModeDescription(View.ClientSize.Width,
                                                                  View.ClientSize.Height, new Rational(60, 1), SlimDX.DXGI.Format.R8G8B8A8_UNorm),
                IsWindowed        = true,
                OutputHandle      = handle,
                SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0),
                SwapEffect        = SlimDX.DXGI.SwapEffect.Discard,
                Usage             = SlimDX.DXGI.Usage.RenderTargetOutput,
                Flags             = SlimDX.DXGI.SwapChainFlags.AllowModeSwitch
            };

            SlimDX.Direct3D10.Device.CreateWithSwapChain(null, SlimDX.Direct3D10.DriverType.Hardware,
                                                         SlimDX.Direct3D10.DeviceCreationFlags.Debug, desc, out Device10, out SwapChain);
            backBuffer = SlimDX.Direct3D10.Texture2D.FromSwapChain <SlimDX.Direct3D10.Texture2D>(SwapChain, 0);
            RenderView = new SlimDX.Direct3D10.RenderTargetView(Device10, backBuffer);

            SlimDX.Direct3D10.Texture2DDescription depthStencilDesc = new SlimDX.Direct3D10.Texture2DDescription
            {
                Width             = View.Width,
                Height            = View.Height,
                MipLevels         = 1,
                ArraySize         = 1,
                Format            = SlimDX.DXGI.Format.D32_Float,
                SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0),
                Usage             = SlimDX.Direct3D10.ResourceUsage.Default,
                BindFlags         = SlimDX.Direct3D10.BindFlags.DepthStencil,
                CpuAccessFlags    = SlimDX.Direct3D10.CpuAccessFlags.None,
                OptionFlags       = SlimDX.Direct3D10.ResourceOptionFlags.None
            };
            depthStencil     = new SlimDX.Direct3D10.Texture2D(Device10, depthStencilDesc);
            DepthStencilView = new SlimDX.Direct3D10.DepthStencilView(Device10, depthStencil,
                                                                      new SlimDX.Direct3D10.DepthStencilViewDescription
            {
                Format          = SlimDX.DXGI.Format.D32_Float,
                FirstArraySlice = 0,
                ArraySize       = 1,
                MipSlice        = 0,
                Dimension       = SlimDX.Direct3D10.DepthStencilViewDimension.Texture2D
            });

            SlimDX.Direct3D10.DepthStencilStateDescription dssd = new SlimDX.Direct3D10.DepthStencilStateDescription
            {
                IsDepthEnabled   = true,
                DepthWriteMask   = SlimDX.Direct3D10.DepthWriteMask.All,
                DepthComparison  = SlimDX.Direct3D10.Comparison.Less,
                IsStencilEnabled = true,
                StencilReadMask  = 0xFF,
                StencilWriteMask = 0xFF,
                FrontFace        = new SlimDX.Direct3D10.DepthStencilOperationDescription
                {
                    FailOperation      = SlimDX.Direct3D10.StencilOperation.Keep,
                    DepthFailOperation = SlimDX.Direct3D10.StencilOperation.Increment,
                    PassOperation      = SlimDX.Direct3D10.StencilOperation.Keep,
                    Comparison         = SlimDX.Direct3D10.Comparison.Always
                },
                BackFace = new SlimDX.Direct3D10.DepthStencilOperationDescription
                {
                    FailOperation      = SlimDX.Direct3D10.StencilOperation.Keep,
                    DepthFailOperation = SlimDX.Direct3D10.StencilOperation.Decrement,
                    PassOperation      = SlimDX.Direct3D10.StencilOperation.Keep,
                    Comparison         = SlimDX.Direct3D10.Comparison.Always
                }
            };

            depthStencilState = SlimDX.Direct3D10.DepthStencilState.FromDescription(Device10, dssd);
            Device10.OutputMerger.DepthStencilState = depthStencilState;
            Device10.OutputMerger.SetTargets(DepthStencilView, RenderView);
            Viewport10 = new SlimDX.Direct3D10.Viewport(0, 0, View.ClientSize.Width, View.ClientSize.Height, 0.0f, 1.0f);
            Device10.Rasterizer.SetViewports(Viewport10);

            //Stops Alt+enter from causing fullscreen skrewiness.
            factory = SwapChain.GetParent <SlimDX.DXGI.Factory>();
            factory.SetWindowAssociation(View.Handle, SlimDX.DXGI.WindowAssociationFlags.IgnoreAll);
        }
        public override void ToggleFullScreen(IntPtr handle)
        {
            //if (LostDevice != null)
            //    LostDevice();

            factory.SetWindowAssociation(handle, SlimDX.DXGI.WindowAssociationFlags.IgnoreAll);

            SwapChain.Dispose();
            backBuffer.Dispose();
            RenderView.Dispose();

            SwapChain = new SlimDX.DXGI.SwapChain(factory, Device10, new SlimDX.DXGI.SwapChainDescription
            {
                BufferCount = 1,
                ModeDescription = new SlimDX.DXGI.ModeDescription(View.ClientSize.Width, View.ClientSize.Height, new Rational(60, 1), SlimDX.DXGI.Format.R8G8B8A8_UNorm),
                IsWindowed = false,
                OutputHandle = handle,
                SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0),
                SwapEffect = SlimDX.DXGI.SwapEffect.Discard,
                Usage = SlimDX.DXGI.Usage.RenderTargetOutput,
                Flags = SlimDX.DXGI.SwapChainFlags.AllowModeSwitch
            });
            backBuffer = SlimDX.Direct3D10.Texture2D.FromSwapChain<SlimDX.Direct3D10.Texture2D>(SwapChain, 0);
            RenderView = new SlimDX.Direct3D10.RenderTargetView(Device10, backBuffer);

            //Create(handle);

            //SwapChain.SetFullScreenState(true, null);

            //if (ResetDevice != null)
            //    ResetDevice();
        }
Ejemplo n.º 19
0
 bool IsShareable(SlimDX.Direct3D10.Texture2D Texture)
 {
     return((Texture.Description.OptionFlags & SlimDX.Direct3D10.ResourceOptionFlags.Shared) != 0);
 }
        public override void Create(IntPtr handle)
        {
            var desc = new SlimDX.DXGI.SwapChainDescription()
            {
                BufferCount = 1,
                ModeDescription = new SlimDX.DXGI.ModeDescription(View.ClientSize.Width,
                    View.ClientSize.Height, new Rational(60, 1), SlimDX.DXGI.Format.R8G8B8A8_UNorm),
                IsWindowed = true,
                OutputHandle = handle,
                SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0),
                SwapEffect = SlimDX.DXGI.SwapEffect.Discard,
                Usage = SlimDX.DXGI.Usage.RenderTargetOutput,
                Flags = SlimDX.DXGI.SwapChainFlags.AllowModeSwitch
            };

            SlimDX.Direct3D10.Device.CreateWithSwapChain(null, SlimDX.Direct3D10.DriverType.Hardware,
                SlimDX.Direct3D10.DeviceCreationFlags.Debug, desc, out Device10, out SwapChain);
            backBuffer = SlimDX.Direct3D10.Texture2D.FromSwapChain<SlimDX.Direct3D10.Texture2D>(SwapChain, 0);
            RenderView = new SlimDX.Direct3D10.RenderTargetView(Device10, backBuffer);

            SlimDX.Direct3D10.Texture2DDescription depthStencilDesc = new SlimDX.Direct3D10.Texture2DDescription
            {
                Width = View.Width,
                Height = View.Height,
                MipLevels = 1,
                ArraySize = 1,
                Format = SlimDX.DXGI.Format.D32_Float,
                SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0),
                Usage = SlimDX.Direct3D10.ResourceUsage.Default,
                BindFlags = SlimDX.Direct3D10.BindFlags.DepthStencil,
                CpuAccessFlags = SlimDX.Direct3D10.CpuAccessFlags.None,
                OptionFlags = SlimDX.Direct3D10.ResourceOptionFlags.None
            };
            depthStencil = new SlimDX.Direct3D10.Texture2D(Device10, depthStencilDesc);
            DepthStencilView = new SlimDX.Direct3D10.DepthStencilView(Device10, depthStencil,
                new SlimDX.Direct3D10.DepthStencilViewDescription
                {
                    Format = SlimDX.DXGI.Format.D32_Float,
                    FirstArraySlice = 0,
                    ArraySize = 1,
                    MipSlice = 0,
                    Dimension = SlimDX.Direct3D10.DepthStencilViewDimension.Texture2D
                });

            SlimDX.Direct3D10.DepthStencilStateDescription dssd = new SlimDX.Direct3D10.DepthStencilStateDescription
            {
                IsDepthEnabled = true,
                DepthWriteMask = SlimDX.Direct3D10.DepthWriteMask.All,
                DepthComparison = SlimDX.Direct3D10.Comparison.Less,
                IsStencilEnabled = true,
                StencilReadMask = 0xFF,
                StencilWriteMask = 0xFF,
                FrontFace = new SlimDX.Direct3D10.DepthStencilOperationDescription
                {
                    FailOperation = SlimDX.Direct3D10.StencilOperation.Keep,
                    DepthFailOperation = SlimDX.Direct3D10.StencilOperation.Increment,
                    PassOperation = SlimDX.Direct3D10.StencilOperation.Keep,
                    Comparison = SlimDX.Direct3D10.Comparison.Always
                },
                BackFace = new SlimDX.Direct3D10.DepthStencilOperationDescription
                {
                    FailOperation = SlimDX.Direct3D10.StencilOperation.Keep,
                    DepthFailOperation = SlimDX.Direct3D10.StencilOperation.Decrement,
                    PassOperation = SlimDX.Direct3D10.StencilOperation.Keep,
                    Comparison = SlimDX.Direct3D10.Comparison.Always
                }
            };

            depthStencilState = SlimDX.Direct3D10.DepthStencilState.FromDescription(Device10, dssd);
            Device10.OutputMerger.DepthStencilState = depthStencilState;
            Device10.OutputMerger.SetTargets(DepthStencilView, RenderView);
            Viewport10 = new SlimDX.Direct3D10.Viewport(0, 0, View.ClientSize.Width, View.ClientSize.Height, 0.0f, 1.0f);
            Device10.Rasterizer.SetViewports(Viewport10);

            //Stops Alt+enter from causing fullscreen skrewiness.
            factory = SwapChain.GetParent<SlimDX.DXGI.Factory>();
            factory.SetWindowAssociation(View.Handle, SlimDX.DXGI.WindowAssociationFlags.IgnoreAll);
        }